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


Python Node.root方法代码示例

本文整理汇总了Python中wheelcms_axle.models.Node.root方法的典型用法代码示例。如果您正苦于以下问题:Python Node.root方法的具体用法?Python Node.root怎么用?Python Node.root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wheelcms_axle.models.Node的用法示例。


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

示例1: test_update_post

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
    def test_update_post(self, client):
        root = Node.root()
        Type1(node=root, title="Hello").save()
        request = superuser_request("/edit", method="POST",
                                      title="Test",
                                      slug="",
                                      language="en")
        handler = MainHandler(request=request, post=True, instance=root)
        pytest.raises(Redirect, handler.update)

        root = Node.root()
        assert root.content().title == "Test"
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:14,代码来源:test_handler.py

示例2: test_create_attach_post

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
    def test_create_attach_post(self, client):
        """ post the form for attaching content """
        request = superuser_request("/create", method="POST",
                                      title="Test", language="en")
        root = Node.root()
        handler = MainHandler(request=request, post=True,
                              instance=dict(instance=root))
        pytest.raises(Redirect, handler.create, type=Type1.get_name(), attach=True)

        root = Node.root()
        # pytest.set_trace()
        assert root.content().title == "Test"
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:14,代码来源:test_handler.py

示例3: test_update_post_unicode

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
    def test_update_post_unicode(self, client):
        """ update content with unicode with new unicode title """
        root = Node.root()
        Type1(node=root, title=u"Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!").save()
        request = superuser_request("/edit", method="POST",
                                      title="TTesting «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!",
                                      slug="",
                                      language="en")
        root = Node.root()
        handler = MainHandler(request=request, post=True, instance=root)
        pytest.raises(Redirect, handler.update)

        root = Node.root()
        assert root.content().title == u"TTesting «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!"
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:16,代码来源:test_handler.py

示例4: test_paste_cut_action

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
    def test_paste_cut_action(self, client):
        """ paste after cut moves content, must be in different node to have
            any effect """
        root = Node.root()
        target = root.add("target")

        t1 = Type1(node=root.add("t1"), title="t1").save()
        t2 = Type1(node=root.add("t2"), title="t2").save()


        request = superuser_request("/contents_actions_cutcopypaste",
                                    method="POST", action="paste",
                                    selection=[t1.node.tree_path,
                                               t2.node.tree_path])
        request.session['clipboard_cut'] = [t2.node.tree_path, t1.node.tree_path]

        handler = MainHandlerTestable(request=request, instance=target,
                                      post=True)

        pytest.raises(Redirect, handler.handle_contents_actions_cutcopypaste)
        assert len(target.children()) == 2
        assert set(x.content().title for x in target.children()) == \
               set(('t1', 't2'))
        assert len(root.children()) == 1
        assert root.child('target')
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:27,代码来源:test_handler.py

示例5: handle

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
    def handle(self, readfrom, update_lm=True, base="", owner="", **options):
        contentxml = os.path.join(readfrom, "content.xml")
        mediadir = os.path.join(readfrom, "media")

        if not os.access(settings.MEDIA_ROOT, os.W_OK):
            print "%s may not be writable. Continue (y/n)?" % settings.MEDIA_ROOT
            if raw_input().lower().strip() != "y":
                print "Exiting"
                return

        data = open(contentxml).read()
        tree = ElementTree.fromstring(data)
        basenode = Node.get(base)
        if basenode is None:
            basenode = Node.root()
            for part in base.strip("/").split("/"):
                sub = basenode.child(part)
                if sub is None:
                    sub = basenode.add(part)
                basenode = sub

        Importer(basenode, update_lm=update_lm).run(tree)

        ## check writability
        if os.path.exists(mediadir):
            copy_tree(mediadir, settings.MEDIA_ROOT)
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:28,代码来源:import.py

示例6: test_form_choices

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
    def test_form_choices(self):
        """ the form should get its choices from the workflow """
        form = Type1Type.form(parent=Node.root())
        wfclass = core.workflow[Type1Type]

        assert form.workflow_choices() == wfclass.states
        assert form.workflow_default() == wfclass.default
开发者ID:wheelcms,项目名称:wheelcms_axle,代码行数:9,代码来源:test_workflow.py

示例7: test_coerce_parent

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
 def test_coerce_parent(self, client):
     """ coerce a dict holding an parent path """
     root = Node.root()
     a = root.add("a")
     res = MainHandler.coerce(dict(parent="a"))
     assert 'parent' in res
     assert res['parent'] == a
     assert 'instance' not in res
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:10,代码来源:test_handler.py

示例8: test_attached_root

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
 def test_attached_root(self, client):
     """ A root node with content attached. Its name should not be
         its title but 'Home' """
     root = Node.root()
     Type1(node=root, title="The rootnode of this site").save()
     request = create_request("GET", "/")
     handler = MainHandlerTestable(request=request, instance=root)
     assert handler.breadcrumb() == [("Home", '')]
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:10,代码来源:test_handler.py

示例9: test_create_get_root

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
 def test_create_get_root(self, client):
     """ test create on root - get """
     root = Node.root()
     Type1(node=root).save()
     request = superuser_request("/", type=Type1.get_name())
     handler = MainHandlerTestable(request=request, instance=root)
     create = handler.create()
     assert create['path'] == "wheelcms_axle/create.html"
     assert 'form' in create['context']
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:11,代码来源:test_handler.py

示例10: test_create_attach_get

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
 def test_create_attach_get(self, client):
     """ get the form for attaching content """
     root = Node.root()
     Type1(node=root).save()
     request = superuser_request("/", type=Type1.get_name())
     handler = MainHandlerTestable(request=request, instance=root)
     create = handler.create(type=Type1.get_name(), attach=True)
     assert create['path'] == "wheelcms_axle/create.html"
     assert 'form' in create['context']
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:11,代码来源:test_handler.py

示例11: test_create_translation_content_post

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
    def test_create_translation_content_post(self, client):
        """ test case where root has content but current language
            is not translated """
        root = Node.root()
        node = root.add("content")
        Type1(node=node, title="Hello", language="en").save()
        request = superuser_request("/edit", method="POST",
                                    title="hello",
                                    language="nl")
        request.session['admin_language'] = 'nl'

        root = Node.root()
        handler = MainHandler(request=request, post=True, instance=node)
        pytest.raises(Redirect, handler.update)

        assert node.content(language='nl')
        assert node.content(language='en')
        assert node.content(language='nl') != node.content(language='en')
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:20,代码来源:test_handler.py

示例12: test_not_visible

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
    def test_not_visible(self, client):
        """ content that's published but not in navigation """
        root = Node.root()
        testable = root.add("sub")
        child = testable.add("child")
        content = Type1(node=child, state="published")
        content.save()

        assert get_visible_children(testable).count() == 0
开发者ID:wheelcms,项目名称:wheelcms_axle,代码行数:11,代码来源:test_queries.py

示例13: test_parent_instance

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
    def test_parent_instance(self, client):
        """ handler initialized with a parent but no instance. Should
            mean edit mode, but for now assume custom breadcrumb context """
        root = Node.root()
        Type1(node=root, title="Root").save()
        request = create_request("GET", "/")
        handler = MainHandlerTestable(request=request, kw=dict(parent=root))

        assert handler.breadcrumb() == []
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:11,代码来源:test_handler.py

示例14: test_coerce_instance_parent

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
 def test_coerce_instance_parent(self, client):
     """ coerce a dict holding both instance and parent """
     root = Node.root()
     a = root.add("a")
     b = a.add("b")
     res = MainHandler.coerce(dict(instance="b", parent="a"))
     assert 'instance' in res
     assert 'parent' in res
     assert res['instance'] == b
     assert res['parent'] == a
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:12,代码来源:test_handler.py

示例15: test_published

# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import root [as 别名]
    def test_published(self, client):
        """ content that's in navigation but not published """
        root = Node.root()
        testable = root.add("sub")
        child = testable.add("child")
        content = Type1(node=child, navigation=True, state="published")
        content.save()

        assert get_visible_children(testable).count() == 1
        assert get_visible_children(testable).get() == content.node
开发者ID:wheelcms,项目名称:wheelcms_axle,代码行数:12,代码来源:test_queries.py


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