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='')
I've tried to use MapperExtension from the official Ming Documentation. and on creating document I'm getting:
t = model.MyMappedClass()
model._session.flush()
TypeError: before_insert() takes exactly 3 arguments (4 given)
It turns out that the MapperExtension
base class has a bug which has now been fixed on the master branch and in the docs.