set_callback exemple not working

17 views
Skip to first unread message

hugoleve...@gmail.com

unread,
Feb 28, 2014, 6:01:59 PM2/28/14
to mogo-...@googlegroups.com
Hey

Was trying your set_callback example but I get an error:

class Ship(Model):
    type = Field(set_callback=lambda x: "Firefly")

ship = Ship(type="firefly")
print ship.type

Traceback (most recent call last):
  File "/Users/hugoleveille/Desktop/programming/db/entity.py", line 171, in <module>
    ship = Ship(type="firefly")
  File "/Users/hugoleveille/Desktop/programming/site-packages/mogo/model.py", line 162, in __init__
    setattr(self, field, value)
  File "/Users/hugoleveille/Desktop/programming/site-packages/mogo/field.py", line 106, in __set__
    value = self._set_callback(instance, value)
TypeError: <lambda>() takes exactly 1 argument (2 given)


Anything missing from this example to make it works?

Thanks
Reply all
Reply to author
Forward
0 new messages