本文整理汇总了Python中ming.orm.Mapper.compile_all方法的典型用法代码示例。如果您正苦于以下问题:Python Mapper.compile_all方法的具体用法?Python Mapper.compile_all怎么用?Python Mapper.compile_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ming.orm.Mapper
的用法示例。
在下文中一共展示了Mapper.compile_all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from ming.orm import Mapper [as 别名]
# 或者: from ming.orm.Mapper import compile_all [as 别名]
def setUp(self):
self.datastore = DS.DataStore(
'mim:///', database='test_db')
self.session = ORMSession(bind=self.datastore)
class BasicMapperExtension(MapperExtension):
def after_insert(self, instance, state):
assert 'clean'==state.status
def before_insert(self, instance, state):
assert 'new'==state.status
def before_update(self, instance, state):
assert 'dirty'==state.status
def after_update(self, instance, state):
assert 'clean'==state.status
class Basic(MappedClass):
class __mongometa__:
name='basic'
session = self.session
extensions = [BasicMapperExtension]
_id = FieldProperty(S.ObjectId)
a = FieldProperty(int)
b = FieldProperty([int])
c = FieldProperty(dict(
d=int, e=int))
Mapper.compile_all()
self.Basic = Basic
self.session.remove(self.Basic)
示例2: setUp
# 需要导入模块: from ming.orm import Mapper [as 别名]
# 或者: from ming.orm.Mapper import compile_all [as 别名]
def setUp(self):
self.datastore = DS.DataStore(
'mim:///', database='test_db')
self.session = ThreadLocalORMSession(Session(bind=self.datastore))
class Parent(MappedClass):
class __mongometa__:
name='parent'
session = self.session
_id = FieldProperty(S.ObjectId)
Mapper.compile_all()
self.Parent = Parent
self.create_app = TestApp(MingMiddleware(self._wsgi_create_object))
self.remove_app = TestApp(MingMiddleware(self._wsgi_remove_object))
self.remove_exc = TestApp(MingMiddleware(self._wsgi_remove_object_exc))
示例3: html_text
# 需要导入模块: from ming.orm import Mapper [as 别名]
# 或者: from ming.orm.Mapper import compile_all [as 别名]
@property
def html_text(self):
"""A markdown processed version of the page text"""
return g.markdown_wiki.cached_convert(self, 'text')
def authors(self):
"""All the users that have edited this page"""
def uniq(users):
t = {}
for user in users:
t[user.username] = user.id
return t.values()
user_ids = uniq([r.author for r in self.history().all()])
return User.query.find({'_id': {'$in': user_ids}}).all()
def delete(self):
Shortlink.query.remove(dict(ref_id=self.index_id()))
self.deleted = True
suffix = " {:%Y-%m-%d %H:%M:%S.%f}".format(datetime.utcnow())
self.title += suffix
class WikiAttachment(BaseAttachment):
ArtifactType = Page
class __mongometa__:
polymorphic_identity = 'WikiAttachment'
attachment_type = FieldProperty(str, if_missing='WikiAttachment')
Mapper.compile_all()