• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: handle

    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,代码行数:26,代码来源:import.py


示例2: test_update_post

    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,代码行数:12,代码来源:test_handler.py


示例3: test_create_post

    def test_create_post(self, client):
        request = superuser_request("/create", method="POST",
                                      title="Test",
                                      slug="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())

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


示例4: test_create_attach_post

    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,代码行数:12,代码来源:test_handler.py


示例5: test_create_post_unicode

    def test_create_post_unicode(self, client):
        """ issue #693 - unicode enoding issue """
        request = superuser_request("/create", method="POST",
                           title=u"Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!",
                           slug="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())

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


示例6: test_update_post_unicode

    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,代码行数:14,代码来源:test_handler.py


示例7: test_create_image

    def test_create_image(self, client):
        request = superuser_request("/create", method="POST",
                                      title="Test",
                                      slug="test",
                                      language="en",
                                      storage=filedata)
        root = Node.root()
        handler = MainHandler(request=request, post=True,
                              instance=dict(instance=root))
        pytest.raises(Redirect, handler.create, type=TestImage.get_name())

        node = Node.get("/test")
        filedata.seek(0)
        assert node.content().storage.read() == filedata.read()
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:14,代码来源:test_handler.py


示例8: test_update_image

    def test_update_image(self, client):
        root = Node.root()
        node = root.add("test")
        TestImage(node=node, title="image", storage=filedata).save()
        request = superuser_request("/test/edit", method="POST",
                                      title="Test",
                                      slug="",
                                      language="en",
                                      storage=filedata2)
        handler = MainHandler(request=request, post=True, instance=node)
        pytest.raises(Redirect, handler.update)

        node = Node.get("/test")
        filedata2.seek(0)
        assert node.content().storage.read() == filedata2.read()
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:15,代码来源:test_handler.py


示例9: test_form_choices

    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,代码行数:7,代码来源:test_workflow.py


示例10: test_handler_create

    def test_handler_create(self, client):
        """ The handler *can* set the user """
        request = create_request("POST", "/create",
                                 data=dict(title="Test",
                                           slug="test",
                                           language="en"))
        request.user = self.user

        root = Node.root()
        handler = MainHandler(request=request, post=True,
                              instance=dict(parent=root))
        pytest.raises(Redirect, handler.create, type=Type1.get_name())

        node = Node.get("/test")
        assert node.content().title == "Test"
        assert node.content().owner == self.user
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:16,代码来源:test_ownership.py


示例11: test_paste_cut_action

    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,代码行数:25,代码来源:test_handler.py


示例12: handle

    def handle(self, writeto=None, path="", *args, **options):
        if writeto is None:
            raise CommandError("You must specificy a writable directory where the export can be written to")

        verbose = options.get('verbose', True)

        mediadir = os.path.join(writeto, "media")
        if not os.path.exists(mediadir):
            os.makedirs(mediadir)

        base = path # "" # /sub5_2/sub4_2/sub3_2"
        root = Node.get(base)
        xml, files = Exporter().run(root, base)
        open(os.path.join(writeto, "content.xml"), "w"
            ).write(prettify(xml).encode("utf8"))
        for file in set(files):
            dirname = os.path.dirname(file)
            if dirname:
                dir = os.path.join(mediadir, dirname)
                if not os.path.exists(dir):
                    os.makedirs(dir)
            dest = os.path.join(mediadir, file)
            source = os.path.join(settings.MEDIA_ROOT, file)

            if verbose:
                print "Copy %s to %s" % (source, dest)
            shutil.copy(source, dest)

        if verbose:
            print files
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:30,代码来源:export.py


示例13: test_coerce_parent

 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,代码行数:8,代码来源:test_handler.py


示例14: test_attached_root

 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,代码行数:8,代码来源:test_handler.py


示例15: test_create_attach_get

 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,代码行数:9,代码来源:test_handler.py


示例16: test_create_get_root

 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,代码行数:9,代码来源:test_handler.py


示例17: test_create_translation_content_post

    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,代码行数:18,代码来源:test_handler.py


示例18: test_parent_instance

    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,代码行数:9,代码来源:test_handler.py


示例19: test_not_visible

    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,代码行数:9,代码来源:test_queries.py


示例20: test_update_root

 def test_update_root(self, client):
     """ test /edit """
     root = Node.root()
     Type1(node=root).save()
     request = superuser_request("/edit", method="POST", type=Type1.get_name())
     instance = MainHandlerTestable.coerce(dict(instance=""))
     handler = MainHandlerTestable(request=request, instance=instance)
     update = handler.update()
     assert update['path'] == "wheelcms_axle/update.html"
     assert 'form' in update['context']
开发者ID:reichertwd,项目名称:wheelcms_axle,代码行数:10,代码来源:test_handler.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python node.Node类代码示例发布时间:2022-05-26
下一篇:
Python util.native函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap