本文整理汇总了Python中MoinMoin.items.Item.create方法的典型用法代码示例。如果您正苦于以下问题:Python Item.create方法的具体用法?Python Item.create怎么用?Python Item.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoinMoin.items.Item
的用法示例。
在下文中一共展示了Item.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_content_diff
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test_get_content_diff(self):
item = self.imw[self.item_name]
rev1 = item.store_revision(dict(name=[self.item_name, ], contenttype='text/plain'),
StringIO(u'x'), trusted=True, return_rev=True)
notification = Notification(app, self.item_name, [rev1], action=ACTION_SAVE)
assert notification.get_content_diff() == ["+ x"]
rev1.data.seek(0, 0)
rev2 = item.store_revision(dict(name=[self.item_name, ], contenttype='text/plain'),
StringIO(u'xx'), trusted=True, return_rev=True)
notification = Notification(app, self.item_name, [rev2, rev1], action=ACTION_SAVE)
assert notification.get_content_diff() == ['- x', '+ xx']
rev2.data.seek(0, 0)
notification = Notification(app, self.item_name, [rev2, rev1], action=ACTION_TRASH)
assert notification.get_content_diff() == ['- xx']
rev2.data.seek(0, 0)
item = Item.create(self.item_name)
notification = Notification(app, self.item_name, [], content=item.rev.data,
meta=rev2.meta, action=DESTROY_REV)
assert notification.get_content_diff() == ['- xx']
rev2.data.seek(0, 0)
item = Item.create(self.item_name)
notification = Notification(app, self.item_name, [], content=item.rev.data,
meta=rev2.meta, action=DESTROY_ALL)
assert notification.get_content_diff() == ['- xx']
示例2: test_subscriptions
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test_subscriptions(self):
pagename = u"Foo:foo 123"
tagname = u"xxx"
regexp = r"\d+"
item = Item.create(pagename)
item._save({NAMESPACE: u"", TAGS: [tagname]})
item = Item.create(pagename)
meta = item.meta
name = u'bar'
password = name
email = "[email protected]"
user.create_user(name, password, email)
the_user = user.User(name=name, password=password)
assert not the_user.is_subscribed_to(item)
the_user.subscribe(NAME, u"SomeOtherPageName", u"")
result = the_user.unsubscribe(NAME, u"OneMorePageName", u"")
assert result is False
subscriptions = [(ITEMID, meta[ITEMID], None),
(NAME, pagename, meta[NAMESPACE]),
(TAGS, tagname, meta[NAMESPACE]),
(NAMEPREFIX, pagename[:4], meta[NAMESPACE]),
(NAMERE, regexp, meta[NAMESPACE])]
for subscription in subscriptions:
keyword, value, namespace = subscription
the_user.subscribe(keyword, value, namespace)
assert the_user.is_subscribed_to(item)
the_user.unsubscribe(keyword, value, namespace, item)
assert not the_user.is_subscribed_to(item)
示例3: test__render_data_diff
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test__render_data_diff(self):
item_name = u'Html_Item'
empty_html = u'<span></span>'
html = u'<span>\ud55c</span>'
meta = {CONTENTTYPE: u'text/html;charset=utf-8'}
item = Item.create(item_name)
item._save(meta, empty_html)
item = Item.create(item_name)
# Unicode test, html escaping
rev1 = update_item(item_name, meta, html)
rev2 = update_item(item_name, {}, u' ')
result = Text._render_data_diff(item.content, rev1, rev2)
assert escape(html) in result
# Unicode test, whitespace
rev1 = update_item(item_name, {}, u'\n\n')
rev2 = update_item(item_name, {}, u'\n \n')
result = Text._render_data_diff(item.content, rev1, rev2)
assert '<span> </span>' in result
# If fairly similar diffs are correctly spanned or not, also check indent
rev1 = update_item(item_name, {}, u'One Two Three Four\nSix\n\ud55c')
rev2 = update_item(item_name, {}, u'Two Three Seven Four\nSix\n\ud55c')
result = Text._render_data_diff(item.content, rev1, rev2)
assert '<span>One </span>Two Three Four' in result
assert 'Two Three <span>Seven </span>Four' in result
# Check for diff_html.diff return types
assert reduce(lambda x, y: x and y, [isinstance(i[1], unicode) and isinstance(i[3], unicode) for i in diff_html.diff(u'One Two Three Four\nSix\n', u'Two Three Seven Four\nSix Seven\n')], True)
示例4: test_rename
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test_rename(self):
name = u'Test_Item'
contenttype = u'text/plain;charset=utf-8'
data = 'test_data'
meta = {'test_key': 'test_value', CONTENTTYPE: contenttype}
comment = u'saved it'
item = Item.create(name)
item._save(meta, data, comment=comment)
# item and its contents before renaming
item = Item.create(name)
assert item.name == u'Test_Item'
assert item.meta[COMMENT] == u'saved it'
new_name = u'Test_new_Item'
item.rename(new_name, comment=u'renamed')
# item at original name and its contents after renaming
item = Item.create(name)
assert item.name == u'Test_Item'
# this should be a fresh, new item, NOT the stuff we renamed:
assert item.meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT
# item at new name and its contents after renaming
item = Item.create(new_name)
assert item.name == u'Test_new_Item'
assert item.meta[NAME_OLD] == [u'Test_Item']
assert item.meta[COMMENT] == u'renamed'
assert item.content.data == u'test_data'
示例5: test_InlineIncludeImage
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test_InlineIncludeImage(self):
# the 3rd parameter, u'', should be a binary string defining a png image, but it is not needed for this simple test
update_item(u'logo.png', {CONTENTTYPE: u'image/png'}, u'')
# simple transclusion
update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'{{logo.png}}')
rendered = Item.create(u'page1').content._render_data()
assert '<p><span class="moin-transclusion" data-href="/logo.png"><img alt="logo.png" src=' in rendered
assert '/logo.png" /></span></p>' in rendered
# simple transclusion with alt text and width
update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'{{logo.png|my alt text|width="100"}}')
rendered = Item.create(u'page1').content._render_data()
assert '<p><span class="moin-transclusion" data-href="/logo.png"><img alt="my alt text" src=' in rendered
assert 'logo.png" width="100" /></span></p>' in rendered
# within paragraph
update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'text {{logo.png}} text')
rendered = Item.create(u'page1').content._render_data()
assert '<p>text <span class="moin-transclusion" data-href="/logo.png"><img alt="logo.png" src=' in rendered
assert '/logo.png" /></span> text</p>' in rendered
# within markup
update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u"Normal ''italic '''bold {{logo.png}} bold''' italic'' normal")
rendered = Item.create(u'page1').content._render_data()
assert '<p>Normal <em>italic <strong>bold <span class="moin-transclusion" data-href="/logo.png"><img alt="logo.png" src=' in rendered
assert '/logo.png" /></span> bold</strong> italic</em> normal</p>' in rendered
# multiple transclusions
update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'{{logo.png}}{{logo.png}}')
rendered = Item.create(u'page1').content._render_data()
assert '<p><span class="moin-transclusion" data-href="/logo.png"><img alt="logo.png" src=' in rendered
assert '/logo.png" /></span><span class="moin-transclusion" data-href="/logo.png"><img alt="logo.png" src=' in rendered
# check for old bug
assert '<p />' not in rendered
assert '<p></p>' not in rendered
示例6: test_rename_acts_only_in_active_name_in_case_there_are_several_names
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test_rename_acts_only_in_active_name_in_case_there_are_several_names(self):
content = u"This is page content"
update_item(u'Page',
{NAME: [u'First',
u'Second',
u'Third',
],
CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, content)
item = Item.create(u'Second')
item.rename(u'New name', comment=u'renamed')
item1 = Item.create(u'First')
assert item1.name == u'First'
assert item1.meta[CONTENTTYPE] == 'text/x.moin.wiki;charset=utf-8'
assert item1.content.data == content
item2 = Item.create(u'New name')
assert item2.name == u'New name'
assert item2.meta[CONTENTTYPE] == 'text/x.moin.wiki;charset=utf-8'
assert item2.content.data == content
item3 = Item.create(u'Third')
assert item3.name == u'Third'
assert item3.meta[CONTENTTYPE] == 'text/x.moin.wiki;charset=utf-8'
assert item3.content.data == content
assert item1.rev.revid == item2.rev.revid == item3.rev.revid
item4 = Item.create(u'Second')
assert item4.meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT
示例7: test_rename_recursion_with_multiple_names_and_children
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test_rename_recursion_with_multiple_names_and_children(self):
update_item(u'Foo', {
CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8',
NAME: [u'Other', u'Page', u'Foo'],
}, u'Parent')
update_item(u'Page/Child', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'Child of Page')
update_item(u'Other/Child2', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'Child of Other')
update_item(u'Another', {
CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8',
NAME: [u'Another', u'Page/Second'],
}, u'Both')
update_item(u'Page/Second/Child', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'Child of Second')
update_item(u'Another/Child', {CONTENTTYPE: u'text/x.moin.wiki;charset=utf-8'}, u'Child of Another')
item = Item.create(u'Page')
item.rename(u'Renamed', comment=u'renamed')
assert Item.create(u'Page/Child').meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT
assert Item.create(u'Renamed/Child').content.data == u'Child of Page'
assert Item.create(u'Page/Second').meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT
assert Item.create(u'Renamed/Second').content.data == u'Both'
assert Item.create(u'Another').content.data == u'Both'
assert Item.create(u'Page/Second/Child').meta[CONTENTTYPE] == CONTENTTYPE_NONEXISTENT
assert Item.create(u'Renamed/Second/Child').content.data == u'Child of Second'
assert Item.create(u'Other/Child2').content.data == u'Child of Other'
assert Item.create(u'Another/Child').content.data == u'Child of Another'
示例8: test_rename
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test_rename(self):
name = u'Test_Item'
contenttype = u'text/plain;charset=utf-8'
data = 'test_data'
meta = {'test_key': 'test_value', CONTENTTYPE: contenttype}
comment = u'saved it'
item = Item.create(name)
item._save(meta, data, comment=comment)
# item and its contents before renaming
item = Item.create(name)
assert item.name == u'Test_Item'
assert item.meta['comment'] == u'saved it'
new_name = u'Test_new_Item'
item.rename(new_name, comment=u'renamed')
# item at original name and its contents after renaming
item = Item.create(name)
assert item.name == u'Test_Item'
# this should be a fresh, new item, NOT the stuff we renamed:
assert item.meta[CONTENTTYPE] == 'application/x-nonexistent'
# item at new name and its contents after renaming
item = Item.create(new_name)
assert item.name == u'Test_new_Item'
assert item.meta['name_old'] == u'Test_Item'
assert item.meta['comment'] == u'renamed'
assert item.data == u'test_data'
示例9: testIndexOnDisconnectedLevels
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def testIndexOnDisconnectedLevels(self):
# create a toplevel and some sub-items
basename = u'Bar'
for name in ['', '/ab', '/ab/cd/ef/gh', '/ij/kl/mn/op', '/ij/kl/rs']:
item = Item.create(basename + name)
item._save({CONTENTTYPE: u'text/plain;charset=utf-8'}, "foo")
baseitem = Item.create(basename)
index = baseitem.get_index()
index = baseitem._connect_levels(index)
assert index == [(u'Bar/ab', u'ab', u'text/plain;charset=utf-8'),
(u'Bar/ab/cd', u'ab/cd', u'application/x-nonexistent'),
(u'Bar/ab/cd/ef', u'ab/cd/ef', u'application/x-nonexistent'),
(u'Bar/ab/cd/ef/gh', u'ab/cd/ef/gh', u'text/plain;charset=utf-8'),
(u'Bar/ij', u'ij', u'application/x-nonexistent'),
(u'Bar/ij/kl', u'ij/kl', u'application/x-nonexistent'),
(u'Bar/ij/kl/mn', u'ij/kl/mn', u'application/x-nonexistent'),
(u'Bar/ij/kl/mn/op', u'ij/kl/mn/op', u'text/plain;charset=utf-8'),
(u'Bar/ij/kl/rs', u'ij/kl/rs', u'text/plain;charset=utf-8')]
flat_index = baseitem.flat_index()
assert flat_index == [(u'Bar/ab', u'ab', u'text/plain;charset=utf-8'),
(u'Bar/ij', u'ij', u'application/x-nonexistent'),
]
示例10: test_ExternalInclude
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test_ExternalInclude(self):
# external include
update_item(u"page1", {CONTENTTYPE: u"text/x.moin.wiki;charset=utf-8"}, u"{{http://moinmo.in}}")
rendered = Item.create(u"page1").content._render_data()
assert (
'<object class="moin-http moin-transclusion" data="http://moinmo.in" data-href="http://moinmo.in">http://moinmo.in</object>'
in rendered
)
# external include embedded within text (object is an inline tag)
update_item(u"page1", {CONTENTTYPE: u"text/x.moin.wiki;charset=utf-8"}, u"before {{http://moinmo.in}} after")
rendered = Item.create(u"page1").content._render_data()
assert (
'<p>before <object class="moin-http moin-transclusion" data="http://moinmo.in" data-href="http://moinmo.in">http://moinmo.in</object> after</p>'
in rendered
)
# external include embedded within text italic and bold markup (object is an inline tag)
update_item(
u"page1",
{CONTENTTYPE: u"text/x.moin.wiki;charset=utf-8"},
u"before ''italic '''bold {{http://moinmo.in}} bold''' italic'' normal",
)
rendered = Item.create(u"page1").content._render_data()
assert (
'<p>before <em>italic <strong>bold <object class="moin-http moin-transclusion" data="http://moinmo.in" data-href="http://moinmo.in">http://moinmo.in</object> bold</strong> italic</em> normal</p>'
in rendered
)
示例11: test_create
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test_create(self):
item = Item.create(self.name, itemtype=ITEMTYPE_BLOG)
item._save(self.meta, self.data, comment=self.comment)
# check save result
item = Item.create(self.name)
assert isinstance(item, Blog)
assert item.itemtype == ITEMTYPE_BLOG
assert item.meta[CONTENTTYPE] == self.contenttype
示例12: setup_method
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def setup_method(self, method):
# create an item
self.item_name = u"foo"
self.tagname = u"XXX"
self.namespace = NAMESPACE_DEFAULT
meta = {CONTENTTYPE: u"text/plain;charset=utf-8", TAGS: [self.tagname]}
item = Item.create(self.item_name)
item._save(meta)
self.item = Item.create(self.item_name)
示例13: test_do_show
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test_do_show(self):
# create a blog item
item = Item.create(self.blog_name, itemtype=ITEMTYPE_BLOG)
item._save(self.blog_meta, self.blog_data, comment=self.comment)
# create a blog entry item
item = Item.create(self.entry_name, itemtype=ITEMTYPE_BLOG_ENTRY)
item._save(self.entry_meta, self.entry_data, comment=self.comment)
data_tokens = [self.blog_data, self.entry_data, ]
self._test_view(self.entry_name, data_tokens=data_tokens)
示例14: test__get_data_diff_html
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test__get_data_diff_html(self):
item_name = u"Test_Item"
item = Item.create(item_name)
contenttype = u'text/plain;charset=utf-8'
meta = {CONTENTTYPE: contenttype}
item._save(meta)
item_ = Item.create(item_name)
oldfile = BytesIO("")
newfile = BytesIO("x")
difflines = item_.content._get_data_diff_html(oldfile, newfile)
assert difflines == [(1, Markup(u''), 1, Markup(u'<span>x</span>'))]
示例15: test_do_show_entries
# 需要导入模块: from MoinMoin.items import Item [as 别名]
# 或者: from MoinMoin.items.Item import create [as 别名]
def test_do_show_entries(self):
item = Item.create(self.name, itemtype=ITEMTYPE_BLOG)
item._save(self.meta, self.data, comment=self.comment)
# store entries without PTIME
for entry in self.entries:
item = Item.create(entry['name'], itemtype=ITEMTYPE_BLOG_ENTRY)
item._save(self.entry_meta, entry['data'], comment=self.comment)
# the blog is not empty
exclude_data_tokens = [self.NO_ENTRIES_MSG, ]
# all stored blog entries are listed on the blog index page
data_tokens = [self.data, ] + [entry['data'] for entry in self.entries]
self._test_view(self.name, data_tokens=data_tokens, exclude_data_tokens=exclude_data_tokens)