当前位置: 首页>>代码示例>>Python>>正文


Python PageOperationMixin.make_description方法代码示例

本文整理汇总了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
开发者ID:Salada,项目名称:ecogwiki,代码行数:57,代码来源:wiki_page.py

示例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))
开发者ID:Sunsoo,项目名称:ecogwiki,代码行数:5,代码来源:test_models.py

示例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))
开发者ID:Sunsoo,项目名称:ecogwiki,代码行数:5,代码来源:test_models.py

示例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))
开发者ID:Sunsoo,项目名称:ecogwiki,代码行数:5,代码来源:test_models.py

示例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))
开发者ID:Sunsoo,项目名称:ecogwiki,代码行数:5,代码来源:test_models.py

示例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))
开发者ID:Sunsoo,项目名称:ecogwiki,代码行数:4,代码来源:test_models.py


注:本文中的models.PageOperationMixin.make_description方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。