本文整理汇总了Python中models.PageOperationMixin.make_description方法的典型用法代码示例。如果您正苦于以下问题:Python PageOperationMixin.make_description方法的具体用法?Python PageOperationMixin.make_description怎么用?Python PageOperationMixin.make_description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.PageOperationMixin
的用法示例。
在下文中一共展示了PageOperationMixin.make_description方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _update_content_all
# 需要导入模块: from models import PageOperationMixin [as 别名]
# 或者: from models.PageOperationMixin import make_description [as 别名]
def _update_content_all(self, body, base_revision, comment, user, force_update, dont_create_rev, dont_defer):
# do not update if the body is not changed
if not force_update and self.body == body:
return False
# validate and prepare new contents
new_data, new_md = self.validate_new_content(base_revision, body, user)
new_body = self._merge_if_needed(base_revision, body)
# get old data and metadata
old_md = self.metadata.copy()
old_data = self.data.copy()
# delete caches
caching.del_rendered_body(self.title)
caching.del_hashbangs(self.title)
caching.del_metadata(self.title)
caching.del_data(self.title)
# update model and save
self.body = new_body
self.modifier = user
self.description = PageOperationMixin.make_description(new_body)
self.acl_read = new_md.get('read', '')
self.acl_write = new_md.get('write', '')
self.comment = comment
self.itemtype_path = schema.get_itemtype_path(new_md['schema'])
self._update_pub_state(new_md, old_md)
if not dont_create_rev:
self.revision += 1
if not force_update:
self.updated_at = datetime.now()
self.put()
# create revision
if not dont_create_rev:
rev_key = self._rev_key()
rev = WikiPageRevision(parent=rev_key, title=self.title, body=self.body,
created_at=self.updated_at, revision=self.revision,
comment=self.comment, modifier=self.modifier,
acl_read=self.acl_read, acl_write=self.acl_write)
rev.put()
# update inlinks, outlinks and schema data index
self.update_links_and_data(old_md.get('redirect'), new_md.get('redirect'), old_data, new_data, dont_defer)
# delete config cache
if self.title == '.config':
caching.del_config()
# delete title cache if it's a new page
if self.revision == 1:
caching.del_titles()
return True
示例2: test_should_ignore_yaml_schema_block
# 需要导入模块: from models import PageOperationMixin [as 别名]
# 或者: from models.PageOperationMixin import make_description [as 别名]
def test_should_ignore_yaml_schema_block(self):
self.assertEqual(u'Hello',
PageOperationMixin.make_description(u'.schema Book\n #!yaml/schema\n author: A\n\nHello', 20))
示例3: test_should_ignore_metadata
# 需要导入模块: from models import PageOperationMixin [as 别名]
# 或者: from models.PageOperationMixin import make_description [as 别名]
def test_should_ignore_metadata(self):
self.assertEqual(u'Hello',
PageOperationMixin.make_description(u'.pub\n\nHello', 20))
示例4: test_cut_off
# 需要导入模块: from models import PageOperationMixin [as 别名]
# 或者: from models.PageOperationMixin import make_description [as 别名]
def test_cut_off(self):
self.assertEqual(u'Hi Hello World Se...',
PageOperationMixin.make_description(u'Hi Hello World Sentences.', 20))
示例5: test_try_period
# 需要导入模块: from models import PageOperationMixin [as 别名]
# 或者: from models.PageOperationMixin import make_description [as 别名]
def test_try_period(self):
self.assertEqual(u'Hi. Hello. World.',
PageOperationMixin.make_description(u'Hi. Hello. World. Sentences.', 20))
示例6: test_try_newline
# 需要导入模块: from models import PageOperationMixin [as 别名]
# 或者: from models.PageOperationMixin import make_description [as 别名]
def test_try_newline(self):
self.assertEqual(u'Hello', PageOperationMixin.make_description(u'Hello\nWorld', 20))