本文整理汇总了Python中wheelcms_axle.models.Node.get方法的典型用法代码示例。如果您正苦于以下问题:Python Node.get方法的具体用法?Python Node.get怎么用?Python Node.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wheelcms_axle.models.Node
的用法示例。
在下文中一共展示了Node.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import get [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)
示例2: handle
# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import get [as 别名]
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
示例3: test_create_post
# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import get [as 别名]
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"
示例4: test_create_post_unicode
# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import get [as 别名]
def test_create_post_unicode(self, client, root):
""" 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",
type=Type1.get_name())
handler = MainHandlerTestable()
res = handler.dispatch(request, nodepath="", handlerpath="create")
assert res.status_code == 302
node = Node.get("/test")
assert node.content().title == u"Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!"
示例5: test_create_post_unicode
# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import get [as 别名]
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!"
示例6: test_create_post
# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import get [as 别名]
def test_create_post(self, client, root):
request = superuser_request("/create", method="POST",
title="Test",
slug="test",
language="en",
type=Type1.get_name())
handler = MainHandlerTestable()
res = handler.dispatch(request, nodepath="", handlerpath="create")
assert res.status_code == 302
node = Node.get("/test")
assert node.content().title == "Test"
示例7: test_create_image
# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import get [as 别名]
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()
示例8: test_create_image
# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import get [as 别名]
def test_create_image(self, client, root):
request = superuser_request("/create", method="POST",
title="Test",
slug="test",
language="en",
storage=filedata,
type=TestImage.get_name())
handler = MainHandlerTestable()
res = handler.dispatch(request, nodepath="", handlerpath="create")
assert res.status_code == 302
node = Node.get("/test")
filedata.seek(0)
assert node.content().storage.read() == filedata.read()
示例9: test_update_image
# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import get [as 别名]
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()
示例10: test_handler_create
# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import get [as 别名]
def test_handler_create(self, superuser, client):
""" The handler *can* set the user """
request = create_request("POST", "/create",
data=dict(title="Test",
slug="test",
language="en",
type=Type1.get_name()))
request.user = superuser
handler = MainHandler()
res = handler.dispatch(request, nodepath="", handlerpath="create")
assert res.status_code == 302
node = Node.get("/test")
assert node.content().title == "Test"
assert node.content().owner == superuser
示例11: test_update_image
# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import get [as 别名]
def test_update_image(self, client, 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 = MainHandlerTestable()
res = handler.dispatch(request, nodepath="/test", handlerpath="edit")
assert res.status_code == 302
node = Node.get("/test")
filedata2.seek(0)
assert node.content().storage.read() == filedata2.read()
示例12: test_handler_create
# 需要导入模块: from wheelcms_axle.models import Node [as 别名]
# 或者: from wheelcms_axle.models.Node import get [as 别名]
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