MongoEngine / eve-mongoengine

An Eve extension for MongoEngine ODM support
Other
39 stars 28 forks source link

mongoengine document methods to eve's hooks? #1

Closed bhanuvrat closed 9 years ago

bhanuvrat commented 10 years ago

being able to define the document specific event hooks (http://python-eve.org/features.html#event-hooks) inside the document class itself would be cool. is it possible to do that? do you have it in your todo list?

hellerstanislav commented 10 years ago

Hello, just to be sure about your feature request: you want to define hook (non-eve hook), which is called within some method bound to document class, right? In example: you want to call some method before or after every document is saved... OK? If this is true, look at mongoengine signals - http://mongoengine-odm.readthedocs.org/guide/signals.html - there is complete list of hooks which mongoengine supports + some howtos. Besides, in eve-mongoengine docs http://eve-mongoengine.readthedocs.org/en/latest/features.html#mongoengine-hooks there is a table which describes which method is called with what HTTP method. Well, it seems now you can use only pre_save and post_save hooks (POST and PUT operations), because every other method is unhookable (mongoengine QuerySet does not support it). If you want to use pre_delete and post_delete hook, let me know and maybe I will come up with some solution.

And just a heads up: hooks are defined to work only on one document. Do not expect to work on set of records - i.e. DELETE resource (many documents) is unhookable.

mmellison commented 9 years ago

Under new management!

We are going to be re-writing a significant portion of the extension. Closing issue. When the new version is released and you feel this issue still has not been resolved, please feel free to open the issue.