Token model instantiation fails in get_decimals()
Closed this issue · 2 comments
nolash commented
Trying to use the token module this happened:
#!/usr/bin/python
from server.models.token import Token
address = "0x0a175a15033c82fbd02bed3fa71bddbf0a12c08f"
name ="FOO"
symbol ="FOO"
t = Token(address=address, name=name, symbol=symbol, decimals=18, token_type='LIQUID')
---
Traceback (most recent call last):
File "foo.py", line 9, in <module>
t = Token(address=address, name=name, symbol=symbol, decimals=18, token_type='LIQUID')
File "<string>", line 4, in __init__
File "/home/lash/src/ext/cic/grassrootseconomics/cic-platform/venv/lib/python3.6/site-packages/sqlalchemy/orm/state.py", line 441, in _initialize_instance
manager.dispatch.init_failure(self, args, kwargs)
File "/home/lash/src/ext/cic/grassrootseconomics/cic-platform/venv/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/home/lash/src/ext/cic/grassrootseconomics/cic-platform/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
raise value
File "/home/lash/src/ext/cic/grassrootseconomics/cic-platform/venv/lib/python3.6/site-packages/sqlalchemy/orm/state.py", line 438, in _initialize_instance
return manager.original_init(*mixed[1:], **kwargs)
File "/home/lash/src/ext/cic/grassrootseconomics/cic-platform/venv/lib/python3.6/site-packages/sqlalchemy/ext/declarative/base.py", line 838, in _declarative_constructor
if not hasattr(cls_, k):
File "/home/lash/src/ext/cic/grassrootseconomics/cic-platform/venv/lib/python3.6/site-packages/sqlalchemy/ext/hybrid.py", line 893, in __get__
return self._expr_comparator(owner)
File "/home/lash/src/ext/cic/grassrootseconomics/cic-platform/venv/lib/python3.6/site-packages/sqlalchemy/ext/hybrid.py", line 1100, in expr_comparator
comparator(owner),
File "/home/lash/src/ext/cic/grassrootseconomics/cic-platform/venv/lib/python3.6/site-packages/sqlalchemy/ext/hybrid.py", line 1085, in _expr
return ExprComparator(cls, expr(cls), self)
File "/home/lash/src/ext/cic/grassrootseconomics/cic-platform/contrib/sempo/app/server/models/token.py", line 70, in decimals
return self.get_decimals()
TypeError: get_decimals() missing 1 required positional argument: 'self'
If I change that line in app/server/models/token.py
to return self,get_decimals(self)
it works. That seems too clumsy to be the solution, though.
enjeyw commented
Hmmm seems to be something to do with the hybrid_property
decorator - if I swap it to a regular property
it behaves fine (would need to QA to see if that's safe to do).
michielderoos commented
Outdated, please reopen if issue persists