本文整理汇总了Python中tiddlyweb.model.tiddler.Tiddler.revision方法的典型用法代码示例。如果您正苦于以下问题:Python Tiddler.revision方法的具体用法?Python Tiddler.revision怎么用?Python Tiddler.revision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.tiddler.Tiddler
的用法示例。
在下文中一共展示了Tiddler.revision方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_interleaved_tiddler_revisions
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def test_interleaved_tiddler_revisions():
bag_name = u"bag8"
for i in xrange(20):
tiddler1 = Tiddler(u"oh yes", bag_name)
tiddler2 = Tiddler(u"oh no", bag_name)
tiddler1.text = u"%s times we yes" % i
tiddler2.text = u"%s times we no" % i
tiddler1.fields[u"%s" % i] = u"%s" % i
tiddler2.fields[u"%s" % i] = u"%s" % i
store.put(tiddler1)
store.put(tiddler2)
revisions = store.list_tiddler_revisions(Tiddler("oh yes", bag_name))
assert len(revisions) == 20
first_revision = revisions[-1]
tiddler = Tiddler("oh yes", bag_name)
tiddler.revision = first_revision + 26
tiddler = store.get(tiddler)
assert tiddler.title == "oh yes"
assert tiddler.text == "13 times we yes"
assert tiddler.fields["13"] == "13"
assert "12" not in tiddler.fields
tiddler.revision = 90
py.test.raises(NoTiddlerError, "store.get(tiddler)")
py.test.raises(NoTiddlerError, 'store.list_tiddler_revisions(Tiddler("sleepy", "cow"))')
示例2: test_tiddler_revisions
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def test_tiddler_revisions():
bag_name = u'bag8'
for i in xrange(20):
tiddler = Tiddler(u'oh hi', bag_name)
tiddler.text = u'%s times we go' % i
tiddler.fields[u'%s' % i] = u'%s' % i
tiddler.fields[u'other%s' % i] = u'%s' % i
tiddler.fields[u'carutther%s' % i] = u'x%s' % i
store.put(tiddler)
revisions = store.list_tiddler_revisions(Tiddler('oh hi', bag_name))
assert len(revisions) == 20
first_revision = revisions[-1]
tiddler = Tiddler(u'oh hi', bag_name)
tiddler.revision = first_revision + 13
tiddler = store.get(tiddler)
assert tiddler.title == 'oh hi'
assert tiddler.text == '13 times we go'
assert tiddler.fields['13'] == '13'
assert tiddler.fields['other13'] == '13'
assert tiddler.fields['carutther13'] == 'x13'
assert '12' not in tiddler.fields
tiddler.revision = 90
py.test.raises(NoTiddlerError, 'store.get(tiddler)')
py.test.raises(NoTiddlerError,
'store.list_tiddler_revisions(Tiddler(u"sleepy", u"cow"))')
示例3: test_revision_get
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def test_revision_get():
bag = Bag('alpha')
STORE.put(bag)
# create a bunch of revisions
tiddler_data = [
{ 'text': 'hello world', 'tags': ['foo'] },
{ 'text': 'lorem ipsum', 'tags': ['foo', 'bar'] },
{ 'text': 'lorem ipsum\ndolor sit amet', 'tags': [] }
]
for tid in tiddler_data:
tiddler = Tiddler('Foo', bag.name)
tiddler.text = tid['text']
tiddler.tags = tid['tags']
STORE.put(tiddler)
tid['revision'] = tiddler.revision
tiddler = Tiddler('Foo', bag.name)
tiddler.revision = None
tiddler = STORE.get(tiddler)
assert tiddler.text == 'lorem ipsum\ndolor sit amet'
assert len(tiddler.tags) == 0
for i, tid in enumerate(tiddler_data):
tiddler = Tiddler('Foo', bag.name)
tiddler.revision = tid['revision']
tiddler = STORE.get(tiddler)
assert tiddler.text == tid['text']
assert len(tiddler.revision) == 10
assert len(tiddler.tags) == len(tid['tags'])
tiddler = Tiddler('Foo', bag.name)
tiddler.revision = 'N/A'
with raises(NoTiddlerError):
STORE.get(tiddler)
示例4: _process_tiddler_revisions
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def _process_tiddler_revisions(self, feed, tiddler, link, do_revisions):
try:
from tiddlywebplugins.differ import compare_tiddlers
except ImportError:
self._add_item(feed, tiddler, link, tiddler.title,
'unable to diff without tiddlywebplugins.differ')
try:
depth = int(do_revisions)
except ValueError:
depth = 1
store = self.environ['tiddlyweb.store']
revision_ids = store.list_tiddler_revisions(tiddler)
while depth >= 0:
try:
rev_older = Tiddler(tiddler.title, tiddler.bag)
rev_older.revision = revision_ids[depth + 1]
rev_older = store.get(rev_older)
except IndexError:
depth -= 1
continue
rev_current = Tiddler(tiddler.title, tiddler.bag)
rev_current.revision = revision_ids[depth]
rev_current = store.get(rev_current)
if binary_tiddler(tiddler):
self._add_item(feed, tiddler, link, tiddler.title,
'Binary Content')
else:
title = '%s comparing version %s to %s' % (tiddler.title,
rev_older.revision, rev_current.revision)
self._add_item(feed, rev_current, link, title,
'<pre>' + compare_tiddlers(rev_older, rev_current)
+ '</pre>')
depth -= 1
示例5: test_interleaved_tiddler_revisions
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def test_interleaved_tiddler_revisions():
bag_name = u'bag8'
for i in xrange(20):
tiddler1 = Tiddler(u'oh yes', bag_name)
tiddler2 = Tiddler(u'oh no', bag_name)
tiddler1.text = u'%s times we yes' % i
tiddler2.text = u'%s times we no' % i
tiddler1.fields[u'%s' % i] = u'%s' % i
tiddler2.fields[u'%s' % i] = u'%s' % i
store.put(tiddler1)
store.put(tiddler2)
revisions = store.list_tiddler_revisions(Tiddler('oh yes', bag_name))
assert len(revisions) == 20
first_revision = revisions[-1]
tiddler = Tiddler('oh yes', bag_name)
tiddler.revision = first_revision + 26
tiddler = store.get(tiddler)
assert tiddler.title == 'oh yes'
assert tiddler.text == '13 times we yes'
assert tiddler.fields['13'] == '13'
assert '12' not in tiddler.fields
tiddler.revision = 9999999 # big number to avoid auto increment issues
py.test.raises(NoTiddlerError, 'store.get(tiddler)')
py.test.raises(NoTiddlerError,
'store.list_tiddler_revisions(Tiddler(u"sleepy", u"cow"))')
示例6: migrate_bags
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def migrate_bags(source, target, bags=None):
"""
Migrate all the bags unless the bags are is set. If it is
then it is assumed to be a list of bags to migrate. Useful
for migrating just one bag.
"""
print "migrate bags"
if bags:
bags = [Bag(bag) for bag in bags]
else:
bags = source.list_bags()
for bag in bags:
bag = source.get(bag)
try:
tiddlers = bag.list_tiddlers()
except AttributeError:
tiddlers = source.list_bag_tiddlers(bag)
target.put(bag)
for tiddler in tiddlers:
for revision_id in reversed(
source.list_tiddler_revisions(tiddler)):
tiddler_revision = Tiddler(tiddler.title, tiddler.bag)
tiddler_revision.revision = revision_id
tiddler_revision = source.get(tiddler_revision)
print "putting tiddler %s:%s in bag %s" % (
tiddler_revision.title.encode('utf-8'),
tiddler_revision.revision,
tiddler_revision.bag.encode('utf-8'))
tiddler_revision.revision = None
target.put(tiddler_revision)
示例7: migrate_bags
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def migrate_bags(source, target):
print "migrate bags"
for bag in source.list_bags():
bag = source.get(bag)
tiddlers = bag.list_tiddlers()
target.put(bag)
for tiddler in tiddlers:
for revision_id in reversed(source.list_tiddler_revisions(tiddler)):
tiddler_revision = Tiddler(tiddler.title, tiddler.bag)
tiddler_revision.revision = revision_id
tiddler_revision = source.get(tiddler_revision)
print "putting tiddler %s:%s in bag %s" % (tiddler_revision.title.encode('utf-8'), tiddler_revision.revision, tiddler_revision.bag.encode('utf-8'))
tiddler_revision.revision = None
target.put(tiddler_revision)
示例8: add
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def add(self, tiddler):
"""
Add a reference to the :py:class:`tiddler
<tiddlyweb.model.tiddler.Tiddler>` to the container, updating the
digest and modified information. If the tiddler has recently been
deleted, resulting in a :py:class:`StoreError
<tiddlyweb.store.StoreError>`, don't add it.
"""
if not tiddler.store and self.store:
try:
tiddler = self.store.get(tiddler)
except StoreError as exc:
LOGGER.debug(
'tried to add missing tiddler to collection: %s, %s',
tiddler, exc)
return
if not self.store.environ['tiddlyweb.config'].get(
'collections.use_memory', False):
reference = Tiddler(tiddler.title, tiddler.bag)
if tiddler.revision:
reference.revision = tiddler.revision
if tiddler.recipe:
reference.recipe = tiddler.recipe
self._container.append(reference)
else:
self._container.append(tiddler)
else:
self._container.append(tiddler)
self._update_digest(tiddler)
modified_string = str(tiddler.modified)
modified_string = modified_string.ljust(14, '0')
if modified_string > self.modified:
self.modified = modified_string
示例9: test_delete_gets_revisions
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def test_delete_gets_revisions():
"""this relies on the previous test"""
removed = Tiddler('tiddler1', 'holder')
store.delete(removed)
revision = Tiddler('tiddler1', 'holder')
revision.revision = 2
py.test.raises(NoTiddlerError, 'store.get(revision)')
示例10: add
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def add(self, tiddler):
"""
Add a reference to the tiddler to the container,
updating the digest and modified information. If
the tiddler has recently been deleted, resulting
in a StoreError, simply don't add it.
"""
if not tiddler.store and self.store:
try:
tiddler = self.store.get(tiddler)
except StoreError, exc:
LOGGER.debug(
'tried to add missing tiddler to collection: %s, %s',
tiddler, exc)
return
if not self.store.environ['tiddlyweb.config'].get(
'collections.use_memory', False):
reference = Tiddler(tiddler.title, tiddler.bag)
if tiddler.revision:
reference.revision = tiddler.revision
if tiddler.recipe:
reference.recipe = tiddler.recipe
self._container.append(reference)
else:
self._container.append(tiddler)
示例11: add
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def add(self, tiddler):
"""
Add a reference to the tiddler to the container,
updating the digest and modified information.
"""
self._update_digest(tiddler)
if self.store:
reference = Tiddler(tiddler.title, tiddler.bag)
if tiddler.revision:
reference.revision = tiddler.revision
if tiddler.recipe:
reference.recipe = tiddler.recipe
self._container.append(reference)
else:
self._container.append(tiddler)
try:
modified_string = str(tiddler.modified)
modified_string = modified_string.ljust(14, '0')
if modified_string > self.modified:
self.modified = modified_string
except AttributeError:
pass
示例12: _send_tiddler_revisions
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def _send_tiddler_revisions(environ, start_response, tiddler):
"""
Push the list of tiddler revisions out the network.
"""
store = environ['tiddlyweb.store']
title = 'Revisions of Tiddler %s' % tiddler.title
title = environ['tiddlyweb.query'].get('title', [title])[0]
container = 'recipes' if tiddler.recipe else 'bags'
if environ['tiddlyweb.filters']:
tiddlers = Tiddlers(title=title)
else:
tiddlers = Tiddlers(title=title, store=store)
tiddlers.is_revisions = True
tiddlers.link = '%s/revisions' % web.tiddler_url(environ, tiddler,
container=container, full=False)
recipe = tiddler.recipe
try:
for revision in store.list_tiddler_revisions(tiddler):
tmp_tiddler = Tiddler(title=tiddler.title, bag=tiddler.bag)
tmp_tiddler.revision = revision
if recipe:
tmp_tiddler.recipe = recipe
tiddlers.add(tmp_tiddler)
except NoTiddlerError, exc:
# If a tiddler is not present in the store.
raise HTTP404('tiddler %s not found, %s' % (tiddler.title, exc))
示例13: test_get_revision
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def test_get_revision():
"""
Test we are able to retrieve a particular revision.
"""
bagone = Bag('bagone')
store.put(bagone)
tiddler = Tiddler('RevisionTiddler')
tiddler.text = 'how now 1'
tiddler.bag = u'bagone'
store.put(tiddler)
tiddler.text = 'how now 2'
store.put(tiddler)
tiddler.text = 'how now 3'
store.put(tiddler)
tiddler = Tiddler('RevisionTiddler', 'bagone')
tiddler = store.get(tiddler)
assert tiddler.text == 'how now 3'
assert tiddler.revision == 3
tiddler = Tiddler('RevisionTiddler', 'bagone')
tiddler.revision = 2
tiddler = store.get(tiddler)
assert tiddler.text == 'how now 2'
assert tiddler.revision == 2
revisions = store.list_tiddler_revisions(tiddler)
assert len(revisions) == 3
assert revisions[0] == 3
示例14: test_revision_type_bug
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def test_revision_type_bug():
tiddler = Tiddler('testtwo', 'pone')
tiddler.text = u'testone'
store.put(tiddler)
store.put(tiddler)
# Invalid revision
tiddler.revision = 'I have a monkey'
py.test.raises(NoTiddlerError, 'tiddler = store.get(tiddler)')
示例15: migrate_bags
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import revision [as 别名]
def migrate_bags(source, target, bags=None):
print "migrate bags"
if bags:
bags = [Bag(bag) for bag in bags]
else:
bags = source.list_bags()
for bag in bags:
bag = source.get(bag)
try:
tiddlers = bag.list_tiddlers()
except AttributeError:
tiddlers = source.list_bag_tiddlers(bag)
target.put(bag)
for tiddler in tiddlers:
for revision_id in reversed(source.list_tiddler_revisions(tiddler)):
tiddler_revision = Tiddler(tiddler.title, tiddler.bag)
tiddler_revision.revision = revision_id
tiddler_revision = source.get(tiddler_revision)
print "putting tiddler %s:%s in bag %s" % (tiddler_revision.title.encode('utf-8'), tiddler_revision.revision, tiddler_revision.bag.encode('utf-8'))
tiddler_revision.revision = None
target.put(tiddler_revision)