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='')
我尝试使用官方Ming文档中的MapperExtension。 以及我正在创建的文档:
t = model.MyMappedClass()
model._session.flush()
TypeError: before_insert() takes exactly 3 arguments (4 given)
答案 0 :(得分:0)
事实证明,MapperExtension
基类有一个错误,现在已在主分支和文档中修复。