本文整理汇总了Python中tiddlyweb.model.tiddler.Tiddler.fields[attr]方法的典型用法代码示例。如果您正苦于以下问题:Python Tiddler.fields[attr]方法的具体用法?Python Tiddler.fields[attr]怎么用?Python Tiddler.fields[attr]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tiddlyweb.model.tiddler.Tiddler
的用法示例。
在下文中一共展示了Tiddler.fields[attr]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_tiddler_div
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields[attr] [as 别名]
def handle_tiddler_div(bagname, tiddler_div, store):
"""
Create a new Tiddler from a tiddler div, in beautifulsoup
form.
"""
new_tiddler = Tiddler(tiddler_div['title'], bag=bagname)
try:
new_tiddler.text = _html_decode(tiddler_div.find('pre').contents[0])
except IndexError:
# there are no contents in the tiddler
new_tiddler.text = ''
for attr, value in tiddler_div.attrs:
data = tiddler_div.get(attr, None)
if data and attr != 'tags':
if attr in (['modifier', 'created', 'modified']):
new_tiddler.__setattr__(attr, data)
else:
new_tiddler.fields[attr] = data
new_tiddler.tags = _tag_string_to_list(tiddler_div.get('tags', ''))
try:
store.put(new_tiddler)
except OSError, exc:
# This tiddler has a name that we can't yet write to the
# store. For now we just state the error and carry on.
import sys
print >> sys.stderr, 'Unable to write %s: %s' % (new_tiddler.title, exc)
示例2: _get_tiddler_from_div
# 需要导入模块: from tiddlyweb.model.tiddler import Tiddler [as 别名]
# 或者: from tiddlyweb.model.tiddler.Tiddler import fields[attr] [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