@post_dump decorator seems to not work
Closed this issue · 4 comments
lorencarvalho commented
Hi!
First off, this is a great package, thank you!
I think the @post_dump
decorator is not working:
>>> from marshmallow_objects import Model, post_dump, fields
>>> class Test(Model):
... foo = fields.Str()
...
... @post_dump
... def test(self, data):
... print('here i am!')
... print(data)
... return data
...
>>> t = Test(**{'foo': 'bar'})
>>> t
Test(**{'foo': 'bar'})
>>> t.dump()
{'foo': 'bar'}
>>>
SVilgelm commented
@sixninetynine Thank you so much.
Could you check again please? On my laptop it works fine:
>>> from marshmallow_objects import Model, post_dump, fields
>>> class Test(Model):
... foo = fields.Str()
... @post_dump
... def test(self, data):
... print('here i am!')
... print(data)
... return data
...
>>> t = Test(**{'foo': 'bar'})
>>> t
here i am!
{'foo': 'bar'}
Test(**{'foo': 'bar'})
>>> t.dump()
here i am!
{'foo': 'bar'}
{'foo': 'bar'}
It seems that in your example the interpreter thinks that the test
function doesn't belong to Test
class. There is unneeded empty string.
lorencarvalho commented
HI @SVilgelm, thanks for the quick reply!
Looks like this is a version incompatibly issue, I just checked and I was using marshmallow 3.0.0b11, after uninstalling the pre-release and testing the same code with marshmallow 2.15.3 it works as expected!
Serves me right for using pre-release software prematurely :)
SVilgelm commented
hmmm, let me check, it should work on 3.0.0....
SVilgelm commented
Uploaded :)