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


Python resources.Content类代码示例

本文整理汇总了Python中kotti.resources.Content的典型用法代码示例。如果您正苦于以下问题:Python Content类的具体用法?Python Content怎么用?Python Content使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Content类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_association_proxy

    def test_association_proxy(self, db_session, events):
        from kotti import DBSession
        from kotti.resources import get_root
        from kotti.resources import Tag, TagsToContents, Content

        root = get_root()
        root[u'content_1'] = Content()
        root[u'content_1'].tags = [u'tag 1', u'tag 2']
        assert root[u'content_1'].tags == [u'tag 1', u'tag 2']
        assert type(root[u'content_1']._tags[0]) == TagsToContents
        assert type(root[u'content_1']._tags[0].tag) == Tag
        assert root[u'content_1']._tags[0].tag.title == u'tag 1'
        assert root[u'content_1']._tags[0].position == 0
        assert root[u'content_1']._tags[1].tag.title == u'tag 2'
        assert root[u'content_1']._tags[1].position == 1
        assert len(root[u'content_1']._tags) == 2

        root[u'content_2'] = Content()
        root[u'content_2'].tags = [u'tag 1', u'tag 3']
        assert len(root[u'content_2']._tags) == 2
        assert root[u'content_2']._tags[0].tag.title == u'tag 1'
        assert root[u'content_2']._tags[0].position == 0
        assert root[u'content_2']._tags[1].tag.title == u'tag 3'
        assert root[u'content_2']._tags[1].position == 1
        assert len(DBSession.query(Tag).all()) == 3
开发者ID:pombredanne,项目名称:Kotti,代码行数:25,代码来源:test_tags.py

示例2: test_include_content_types

    def test_include_content_types(self):
        root = get_root()
        set_nav_setting('left', 'display_type', 'tree')
        set_nav_setting('left', 'options', ['stacked', 'include_root'])

        root[u'content_1'] = Content()
        root[u'content_2'] = Content()
        root[u'content_2'].in_navigation = False

        # If we include the content type the nav item is present.
        set_nav_setting('left', 'include', [Content.type_info.name])
        html = render_view(root, self.request, name='navigation-widget-tree')
        assert u'content_1' in html
        assert u'content_2' not in html

        # With an empty include_content_types, the nav item is not present.
        set_nav_setting('left', 'include', [])
        html = render_view(root, self.request, name='navigation-widget-tree')
        assert u'content_1' in html
        assert u'content_2' not in html

        # Again, with show_hidden True.
        set_nav_setting('left', 'options', ['stacked', 'include_root',
                                            'show_hidden_while_logged_in'])
        with patch('kotti_navigation.util.the_user', return_value='admin'):
            html = render_view(root, self.request,
                               name='navigation-widget-tree')
            assert u'content_1' in html
            assert u'content_2' in html
开发者ID:Kotti,项目名称:kotti_navigation,代码行数:29,代码来源:test_navigation.py

示例3: test_delete_tag_doesnt_touch_content

    def test_delete_tag_doesnt_touch_content(self, root, db_session):
        from kotti.resources import Tag, Content

        root['content_1'] = Content()
        root['content_1'].tags = ['my tag']

        assert Content.query.filter_by(name='content_1').count() == 1
        db_session.delete(Tag.query.filter_by(title='my tag').one())
        assert Content.query.filter_by(name='content_1').count() == 1
开发者ID:castaf,项目名称:Kotti,代码行数:9,代码来源:test_tags.py

示例4: test_delete_tag_assignment_delete_tag

    def test_delete_tag_assignment_delete_tag(self, root, events, db_session):
        from kotti.resources import Tag, TagsToContents, Content

        root['content_1'] = Content()
        root['content_1'].tags = ['my tag']

        assert Tag.query.count() == 1
        db_session.delete(TagsToContents.query.one())
        assert Tag.query.count() == 0
开发者ID:castaf,项目名称:Kotti,代码行数:9,代码来源:test_tags.py

示例5: test_delete_tag_assignment_doesnt_touch_content

    def test_delete_tag_assignment_doesnt_touch_content(self, root, db_session):
        from kotti.resources import Tag, TagsToContents, Content

        root[u'content_1'] = Content()
        root[u'content_1'].tags = [u'my tag']

        assert Tag.query.count() == 1
        assert Content.query.filter_by(name=u'content_1').count() == 1
        db_session.delete(TagsToContents.query.one())
        assert Content.query.filter_by(name=u'content_1').count() == 1
开发者ID:disko,项目名称:Kotti,代码行数:10,代码来源:test_tags.py

示例6: test_delete_content_deletes_orphaned_tags

    def test_delete_content_deletes_orphaned_tags(self, root, events):
        from kotti.resources import Tag, Content

        root['content_1'] = Content()
        root['content_2'] = Content()
        root['content_1'].tags = ['tag 1', 'tag 2']
        root['content_2'].tags = ['tag 2']
        assert Tag.query.count() == 2
        del root['content_1']
        assert Tag.query.one().title == 'tag 2'
开发者ID:castaf,项目名称:Kotti,代码行数:10,代码来源:test_tags.py

示例7: test_delete_tag_assignment_delete_tag

    def test_delete_tag_assignment_delete_tag(self, db_session, events):
        from kotti import DBSession
        from kotti.resources import get_root
        from kotti.resources import Tag, TagsToContents, Content

        root = get_root()
        root[u'content_1'] = Content()
        root[u'content_1'].tags = [u'my tag']

        ses = DBSession
        assert ses.query(Tag).count() == 1
        ses.delete(ses.query(TagsToContents).one())
        assert ses.query(Tag).count() == 0
开发者ID:pombredanne,项目名称:Kotti,代码行数:13,代码来源:test_tags.py

示例8: test_delete_tag_doesnt_touch_content

    def test_delete_tag_doesnt_touch_content(self, db_session, events):
        from kotti import DBSession
        from kotti.resources import get_root
        from kotti.resources import Tag, Content

        root = get_root()
        root[u'content_1'] = Content()
        root[u'content_1'].tags = [u'my tag']

        ses = DBSession
        assert ses.query(Content).filter_by(name=u'content_1').count() == 1
        ses.delete(ses.query(Tag).filter_by(title=u'my tag').one())
        assert ses.query(Content).filter_by(name=u'content_1').count() == 1
开发者ID:pombredanne,项目名称:Kotti,代码行数:13,代码来源:test_tags.py

示例9: test_delete_content_deletes_orphaned_tags

    def test_delete_content_deletes_orphaned_tags(self, db_session, events):
        from kotti import DBSession
        from kotti.resources import get_root
        from kotti.resources import Tag, Content

        root = get_root()
        root[u'content_1'] = Content()
        root[u'content_2'] = Content()
        root[u'content_1'].tags = [u'tag 1', u'tag 2']
        root[u'content_2'].tags = [u'tag 2']
        assert DBSession.query(Tag).count() == 2
        del root[u'content_1']
        assert DBSession.query(Tag).one().title == u'tag 2'
开发者ID:pombredanne,项目名称:Kotti,代码行数:13,代码来源:test_tags.py

示例10: test_reset_owner_to_none

    def test_reset_owner_to_none(self, events, extra_principals, root):
        from kotti.resources import Content
        from kotti.views.users import user_delete

        request = DummyRequest()

        root["content_1"] = Content()
        root["content_1"].owner = "bob"
        assert root["content_1"].owner == "bob"

        request.params["name"] = "bob"
        request.params["delete"] = "delete"
        user_delete(root, request)
        assert root["content_1"].owner is None
开发者ID:Kotti,项目名称:Kotti,代码行数:14,代码来源:test_security_views.py

示例11: test_reset_owner_to_none

    def test_reset_owner_to_none(self, events, extra_principals, root):
        from kotti.resources import Content
        from kotti.views.users import user_delete

        request = DummyRequest()

        root[u'content_1'] = Content()
        root[u'content_1'].owner = u'bob'
        assert root[u'content_1'].owner == u'bob'

        request.params['name'] = u'bob'
        request.params['delete'] = u'delete'
        user_delete(root, request)
        assert root[u'content_1'].owner is None
开发者ID:adamchainz,项目名称:Kotti,代码行数:14,代码来源:test_security_views.py

示例12: test_copy_content_copy_tags

    def test_copy_content_copy_tags(self, root, db_session):
        from kotti.resources import Tag, TagsToContents, Content

        root['content_1'] = Content()
        root['content_1'].tags = ['my tag']
        assert Tag.query.count() == 1
        assert TagsToContents.query.count() == 1

        root['content_2'] = root['content_1'].copy()
        db_session.flush()
        assert root['content_1'].tags == ['my tag']
        assert root['content_2'].tags == ['my tag']
        assert Tag.query.count() == 1
        assert TagsToContents.query.count() == 2
开发者ID:castaf,项目名称:Kotti,代码行数:14,代码来源:test_tags.py

示例13: test_cut_and_paste_content_copy_tags

    def test_cut_and_paste_content_copy_tags(self, root):
        from kotti.resources import Tag, TagsToContents, Content
        from kotti.views.edit.actions import NodeActions

        root["folder_1"] = Content()
        root["content_1"] = Content()
        root["content_1"].tags = ["my tag"]
        assert Tag.query.count() == 1
        assert TagsToContents.query.count() == 1

        request = DummyRequest()
        request.params["paste"] = "on"
        request.session["kotti.paste"] = ([root["content_1"].id], "cut")
        NodeActions(root["folder_1"], request).paste_nodes()
        assert root["folder_1"]["content_1"].tags == ["my tag"]
        assert Tag.query.count() == 1
        assert TagsToContents.query.count() == 1
开发者ID:Kotti,项目名称:Kotti,代码行数:17,代码来源:test_tags.py

示例14: test_show_hidden

    def test_show_hidden(self):
        root = get_root()
        request = DummyRequest()
        root[u'content_1'] = Content()
        root[u'content_2'] = Content()
        root[u'content_2'].in_navigation = False

        # with standard settings the hidden nav points are hidden
        html = render_view(root, request, name='navigation-widget')
        assert u'content_1' in html
        assert u'content_2' not in html

        # if we change the setting, the nav points still hidden
        get_current_registry().settings['kotti_navigation.navigation_widget.show_hidden_while_logged_in'] = u'true'
        html = render_view(root, request, name='navigation-widget')
        assert u'content_1' in html
        assert u'content_2' not in html
开发者ID:igudym,项目名称:kotti_navigation,代码行数:17,代码来源:test_navigation.py

示例15: test_reset_owner_to_none

    def test_reset_owner_to_none(self):
        from kotti.resources import get_root
        from kotti.resources import Content
        from kotti.views.users import user_delete
        from kotti.tests.test_node_views import TestNodeShare

        root = get_root()
        request = DummyRequest()
        TestNodeShare.add_some_principals()

        root[u'content_1'] = Content()
        root[u'content_1'].owner = u'bob'
        assert root[u'content_1'].owner == u'bob'

        request.params['name'] = u'bob'
        request.params['delete'] = u'delete'
        user_delete(root, request)
        assert root[u'content_1'].owner == None
开发者ID:chrneumann,项目名称:Kotti,代码行数:18,代码来源:test_security_views.py


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