本文整理汇总了Python中tiddlyweb.model.tiddler.Tiddler.modified方法的典型用法代码示例。如果您正苦于以下问题:Python Tiddler.modified方法的具体用法?Python Tiddler.modified怎么用?Python Tiddler.modified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.tiddler.Tiddler
的用法示例。
在下文中一共展示了Tiddler.modified方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filter_by_since
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
def test_filter_by_since():
"""
Get the tiddlers modified since <timespec>.
"""
tiddler_old = Tiddler('old')
tiddler_old.modified = '19691009000000'
tiddler_new = Tiddler('new')
tiddler_new.modified = '20090401030303'
found_tiddlers = filter('select=modified:>20010101010100', [tiddler_old, tiddler_new])
assert len(found_tiddlers) == 1
assert found_tiddlers[0].title == 'new'
found_tiddlers = filter('select=modified:>200101010101', [tiddler_old, tiddler_new])
assert len(found_tiddlers) == 1
assert found_tiddlers[0].title == 'new'
示例2: test_tiddler_collection
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
def test_tiddler_collection():
tiddlers = Tiddlers()
n = 4
for title in ['how', 'now', 'cow']:
n = n - 1
tiddler = Tiddler(title, 'bag')
tiddler.modified = n
tiddlers.add(tiddler)
digest = tiddlers.hexdigest()
modified = tiddlers.modified
assert ['how', 'now', 'cow'] == list(tiddler.title for tiddler in tiddlers)
assert modified == '30000000000000'
示例3: test_simple_get
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
def test_simple_get():
"""
get a tiddler that had been stored
"""
stored_tiddler = Tiddler('TiddlerOne')
stored_tiddler.bag = u'bagone'
stored_tiddler.modified = '200803030303'
stored_tiddler = store.get(stored_tiddler)
assert stored_tiddler.title == 'TiddlerOne'
assert stored_tiddler.bag == 'bagone'
assert stored_tiddler.text == 'c tiddler one content'
assert sorted(stored_tiddler.tags) == ['tag five', 'tagone', 'tagtwo']
示例4: test_tiddler_creation_info
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
def test_tiddler_creation_info():
bag = Bag('alpha')
STORE.put(bag)
tiddler = Tiddler('Foo', bag.name)
tiddler.text = 'lorem ipsum'
tiddler.modifier = 'john'
tiddler.modified = '20130119150632'
STORE.put(tiddler)
tiddler = Tiddler('Foo', bag.name)
tiddler.text = 'lorem ipsum\ndolor sit amet'
tiddler.modifier = 'jane'
tiddler.modified = '20130119151021'
STORE.put(tiddler)
tiddler = Tiddler('Foo', bag.name)
tiddler = STORE.get(tiddler)
assert tiddler.creator == 'john'
assert tiddler.modifier == 'jane'
assert tiddler.created != tiddler.modified
assert len(tiddler.created) == 14
assert len(tiddler.fields) == 0
示例5: test_simple_get
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
def test_simple_get():
"""
get a tiddler that had been stored in bagfour
"""
stored_tiddler = Tiddler(title='TiddlerOne')
stored_tiddler.bag = u'bagone'
stored_tiddler.modified = '200803030303'
stored_tiddler = store.get(stored_tiddler)
assert stored_tiddler.title == 'TiddlerOne', 'retrieved tiddler has correct title'
assert stored_tiddler.bag == 'bagone', 'retrieve tiddler has correct bag'
assert stored_tiddler.text == 'c tiddler one content', 'text is %s should b %s' % (stored_tiddler.text, 'c tiddler one content\n')
assert sorted(stored_tiddler.tags) == ['tag five', 'tagone', 'tagtwo']
示例6: test_select
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
def test_select():
# cook some known modified strings in the past
nowstring = current_timestring()
now = int(nowstring)
yearago = str(now - 10000000101)
dayago = str(now - 1000101)
tiddlers = []
tiddler = Tiddler('now')
tiddler.modified = nowstring
tiddlers.append(tiddler)
tiddler = Tiddler('year')
tiddler.modified = yearago
tiddlers.append(tiddler)
tiddler = Tiddler('day')
tiddler.modified = dayago
tiddlers.append(tiddler)
results = list(filter_tiddlers(tiddlers, 'select=modified:<1y'))
assert len(results) == 1
assert results[0].title == 'year'
results = list(filter_tiddlers(tiddlers, 'select=modified:>1y'))
assert len(results) == 2
assert sorted(tiddler.title for tiddler in results) == ['day', 'now']
results = list(filter_tiddlers(tiddlers, 'select=modified:<1d'))
assert len(results) == 2
assert sorted(tiddler.title for tiddler in results) == ['day', 'year']
results = list(filter_tiddlers(tiddlers, 'select=modified:>1m'))
assert len(results) == 1
assert results[0].title == 'now'
示例7: create_tiddler
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
def create_tiddler(store, bag, numeral):
tiddler = Tiddler('tiddler%s' % numeral)
tiddler.bag = bag.name
tiddler.text = u'i am tiddler %s' % numeral
tags = [u'basic tag']
if not numeral % 2:
tags.append(u'tagtwo')
if not numeral % 3:
tags.append(u'tagthree')
if not numeral % 4:
tags.append(u'tagfour')
tiddler.tags = tags
if tiddler.title == 'tiddler8':
tiddler.modified = '200805230303'
store.put(tiddler)
示例8: test_lt_gt
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
def test_lt_gt():
tiddlers = []
dummy = "20050322134706"
dates = ["20091203","20081203","20080403","20090903","20090331","20071103",dummy,dummy,dummy,dummy,dummy,dummy]
for i in [1,2,4,6,10,12,55,90,100,201,323,2223]:#12
tid = Tiddler("foo%s"%i)
tid.fields['foo'] = "%s"%i
try:
tid.modified = dates.pop()
except IndexError:
pass
tiddlers.append(tid)
restiddlers = ltgt.lt("foo:10",tiddlers)
result = []
for tid in restiddlers:
result.append(tid)
assert 4 is len(result)
restiddlers = ltgt.lt("foo:1",tiddlers)
result = []
for tid in restiddlers:
result.append(tid)
assert 0 is len(result)
restiddlers = ltgt.gt("foo:300",tiddlers)
result = []
for tid in restiddlers:
result.append(tid)
assert 2 is len(result)
restiddlers = ltgt.gt("modified:20081101",tiddlers)
result = []
for tid in restiddlers:
print tid.modified
result.append(tid)
assert 4 is len(result)
restiddlers = ltgt.lt("modified:20050323",tiddlers)
result = []
for tid in restiddlers:
print tid.modified
result.append(tid)
assert 6 is len(result)
示例9: _get_tiddler_from_div
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
def _get_tiddler_from_div(node):
"""
Create a Tiddler from an HTML div element.
"""
tiddler = Tiddler(node.getAttribute('title'))
tiddler.text = _html_decode(_get_text(node.getElementsByTagName('pre')))
for attr, value in node.attributes.items():
data = value
if data and attr != 'tags':
if attr in (['modifier', 'created', 'modified']):
tiddler.__setattr__(attr, data)
elif (attr not in ['title', 'changecount'] and
not attr.startswith('server.')):
tiddler.fields[attr] = data
if not node.attributes.get('modified', None) and tiddler.created:
tiddler.modified = tiddler.created
tiddler.tags = string_to_tags_list(str(node.getAttribute('tags')))
return tiddler
示例10: test_store_tiddler
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
def test_store_tiddler():
tiddler = Tiddler('monkey', 'testone')
tiddler.text = 'cow'
tiddler.tags = ['tagone', 'tagtwo', 'tagthree']
tiddler.fields['field key one'] = 'fieldvalueone'
tiddler.fields['field key two'] = 'fieldvaluetwo'
tiddler.modifier = 'cdent'
tiddler.modified = '20080202111111'
store.put(tiddler)
tiddler2 = Tiddler('monkey', 'testone')
tiddler2 = store.get(tiddler2)
assert tiddler.text == tiddler2.text
assert sorted(tiddler.tags) == sorted(tiddler2.tags)
assert tiddler.fields['field key two'] == tiddler2.fields['field key two']
assert tiddler.modifier == tiddler2.modifier
assert tiddler.modified == tiddler2.modified
tiddler2.text = 'pig'
store.put(tiddler2)
revisions = store.list_tiddler_revisions(tiddler2)
assert len(revisions) == 2
store.delete(tiddler2)
py.test.raises(NoTiddlerError, 'store.get(tiddler2)')
store.put(tiddler2)
revisions = store.list_tiddler_revisions(tiddler2)
assert len(revisions) == 1
store.delete(Bag('testone'))
py.test.raises(NoTiddlerError, 'store.get(tiddler2)')
示例11: test_store_tiddler
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
def test_store_tiddler():
tiddler = Tiddler(name, name)
tiddler.text = name
tiddler.tags = [name]
tiddler.fields['field key ' + name + ' one'] = name
tiddler.fields['field key ' + name + ' two'] = name
tiddler.modifier = name
tiddler.modified = '20080202111111'
store.put(tiddler)
tiddler2 = Tiddler(name, name)
tiddler2 = store.get(tiddler2)
assert tiddler.text == tiddler2.text
assert sorted(tiddler.tags) == sorted(tiddler2.tags)
assert tiddler.fields['field key ' + name + ' two'] == tiddler2.fields['field key ' + name + ' two']
assert tiddler.modifier == tiddler2.modifier
assert tiddler.modified == tiddler2.modified
tiddler2.text = 'pig'
store.put(tiddler2)
revisions = store.list_tiddler_revisions(tiddler2)
assert len(revisions) == 2
store.delete(tiddler2)
py.test.raises(NoTiddlerError, 'store.get(tiddler2)')
store.put(tiddler2)
revisions = store.list_tiddler_revisions(tiddler2)
assert len(revisions) == 1
store.delete(Bag(name))
py.test.raises(NoTiddlerError, 'store.get(tiddler2)')
示例12: edit
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
def edit(environ, start_response):
"""
XXX: Lots of duplication from editor.
"""
store = environ['tiddlyweb.store']
usersign = environ['tiddlyweb.usersign']
query = environ['tiddlyweb.query']
try:
bag_name = query['bag'][0]
title = query['title'][0]
text = query['text'][0]
tiddler_type = query['type'][0]
tags = query['tags'][0]
etag = query['etag'][0]
except KeyError as exc:
raise HTTP400('bad query: incomplete form, %s' % exc)
tags = [tag.strip() for tag in tags.split(',')]
if not (bag_name and title):
raise HTTP400('bad query: bag and title required')
bag = Bag(bag_name)
try:
bag = store.get(bag)
except NoBagError:
raise HTTP404('that tank does not exist')
tiddler = Tiddler(title, bag_name)
tiddler_new = False
conflict = False
try:
tiddler = store.get(tiddler)
existing_etag = tiddler_etag(environ, tiddler).replace('"',
'').split(':', 1)[0]
if etag != existing_etag:
conflict = True
except NoTiddlerError:
tiddler.type = tiddler_type
tiddler_new = True
if tiddler_new:
bag.policy.allows(usersign, 'create')
else:
bag.policy.allows(usersign, 'write')
tiddler.text = text
tiddler.tags = tags
tiddler.modifier = usersign['name']
tiddler.modified = current_timestring()
if conflict:
return editor(environ, start_response, tiddler,
message='conflict')
try:
validate_tiddler(tiddler, environ)
except InvalidTiddlerError as exc:
return editor(environ, start_response, tiddler,
message='Tiddler content is invalid: %s' % exc)
store.put(tiddler)
redirect_uri = tank_page_uri(environ, tiddler.bag, tiddler.title)
start_response('303 See Other', [
('Location', str(redirect_uri))])
return []
示例13: Tiddler
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
# cosmic rays have injected noise into this tiddler string
bad_string = """modifiXr: [email protected]
modiFied: 200803030303
tags:foobar [[foo bar]]
Hello, I'm the content.
"""
expected_json_string = '{"created": "", "text": "Hello, I\'m the content.", "modifier": "[email protected]", "modified": "200803030303", "tags": ["foobar", "foo bar"]}'
tiddler = Tiddler('test tiddler')
tiddler.bag = 'snoop'
tiddler.modifier = '[email protected]'
tiddler.tags = ['foobar', 'foo bar']
tiddler.text = "Hello, I'm the content."
tiddler.modified = '200803030303'
def setup_module(module):
pass
def test_generated_txt_string():
serializer = Serializer('text')
serializer.object = tiddler
string = serializer.to_string()
assert string == expected_string
assert '%s' % serializer == expected_string, \
'serializer goes to string as expected_string'
def test_bad_string_raises():
serializer = Serializer('text')
示例14: Tiddler
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
from tiddlywebplugins.wikklytextplugins.plugins import macros
from tiddlyweb.model.tiddler import Tiddler
from tiddlywebplugins import wikklytextplugins
from tiddlywebplugins import wikklytextrender
from tiddlyweb.config import config
from test_common import WikiArgument,WikiContext
test_tiddler= Tiddler("Test Tiddler","bag")
test_tiddler.modified = "20071003201000"
test_tiddler.revision = 2
def test_view_date():
out = macros.view(WikiContext(test_tiddler,{}), WikiArgument("modified"),WikiArgument("date"))
assert '03 October 2007' in out
def test_view_text():
text ="My name is the test tiddler!"
test_tiddler.text = text
test_tiddler.tags = ["jon","ben","jeremy ruston"]
out = macros.view(WikiContext(test_tiddler,{}), WikiArgument("text"))
assert text in out
out = macros.view(WikiContext(test_tiddler,{}), WikiArgument("text"),WikiArgument("text"))
assert text in out
out = macros.view(WikiContext(test_tiddler,{}), WikiArgument("title"),WikiArgument("text"))
assert 'Test Tiddler' in out
out = macros.view(WikiContext(test_tiddler,{}), WikiArgument("server.bag"),WikiArgument("text"))
assert 'bag' in out
out = macros.view(WikiContext(test_tiddler,{}), WikiArgument("server.page.revision"),WikiArgument("text"))
assert '2' in out
示例15: Tiddler
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import modified [as 别名]
bad_string = """modifiXr: [email protected]
created:
modiFied: 200803030303
type: None
tags:foobar [[foo bar]]
Hello, I'm the content.
"""
expected_json_string = '{"created": "", "text": "Hello, I\'m the content.", "modifier": "[email protected]", "modified": "200803030303", "tags": ["foobar", "foo bar"]}'
tiddler = Tiddler("test tiddler")
tiddler.modifier = "[email protected]"
tiddler.tags = ["foobar", "foo bar"]
tiddler.text = "Hello, I'm the content."
tiddler.modified = "200803030303"
def setup_module(module):
pass
def test_generated_txt_string():
serializer = Serializer("text")
serializer.object = tiddler
string = serializer.to_string()
assert string == expected_string, "serialized recipe looks like we expect. should be %s, got %s" % (
expected_string,
string,
)