from ming.odm.mapper import MapperExtension
class MyExtension(MapperExtension):
def after_insert(self, obj, st):
print "instance %s after insert !" % obj
class MyMappedClass(MappedClass):
class __mongometa__:
session = session
name = 'my_mapped_class'
extensions = [ MyExtension ]
_id = FieldProperty(schema.ObjectId)
data = FieldProperty(schema.String,if_missing='')
Я пытался использовать MapperExtension из официальной документации Ming.
и при создании документа я получаю:
t = model.MyMappedClass()
model._session.flush()
TypeError: before_insert() takes exactly 3 arguments (4 given)