本文整理汇总了Python中tiddlyweb.model.tiddler.Tiddler类的典型用法代码示例。如果您正苦于以下问题:Python Tiddler类的具体用法?Python Tiddler怎么用?Python Tiddler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tiddler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_subscribe_bad_atom
def test_subscribe_bad_atom():
# setup
setup(store)
empty = Tiddler("bags/osmosoft_private/bad", "subscriptions.daily")
empty.text = """[email protected]
[email protected]
"""
twhost = environ["tiddlyweb.config"]["server_host"]["host"]
expected = (
u"""note you can subscribe to this feed via atom feed <%s/test/bags/osmosoft_private/bad.atom>
one <two>
Saint_Barth\xe9lemy <three>
"""
% twhost
)
# run
email = mailer.make_digest_email(
empty, environ
) # now since there was no changes to the store you would expect no email
# verify
assert email["body"] == expected
开发者ID:jdlrobson,项目名称:tiddlywebplugins.email,代码行数:28,代码来源:test_subscriptions.py
示例2: test_emoji_title
def test_emoji_title():
"""
We expect this to fail because we're using a) old mysql
b) without the utf8mb4 encoding type.
See: https://github.com/TiddlySpace/tiddlyspace/issues/1033
The fix is to use mysql 5.5 or beyond.
"""
# emoji smiley of some sort
title = '\xF0\x9F\x98\x97'.decode('utf-8')
store.put(Bag(title))
tiddler = Tiddler(title, title)
tiddler.text = u'some stuff and zomg %s' % title
tiddler.tags = [title]
tiddler.fields[title] = title
store.put(tiddler)
tiddler2 = store.get(Tiddler(title, title))
assert tiddler2.title == title
assert tiddler2.text == tiddler.text
assert tiddler2.tags == tiddler.tags
assert tiddler2.tags[0] == title
assert tiddler2.fields[title] == tiddler.fields[title]
assert tiddler2.fields[title] == title
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.mysql,代码行数:26,代码来源:test_gamut.py
示例3: test_refresh_urls
def test_refresh_urls():
"""
register a url after the server has been started, and then refresh them
"""
store = setup_store()
urls_init(config)
setup_web()
http = httplib2.Http()
tiddler = Tiddler('bar', 'foo')
tiddler.text = 'foo bar'
store.put(tiddler)
#check that no url exists yet
response = http.request('http://test_domain:8001/foo')[0]
assert response.status == 404
url(['/foo', '/bags/foo/tiddlers/bar'])
#resfresh the currently loaded set of urls
response = http.request('http://test_domain:8001/urls/refresh')[0]
assert response.status == 200
#now check it was loaded successfully
response = http.request('http://test_domain:8001/foo')[0]
assert response.status == 200
开发者ID:bengillies,项目名称:tiddlywebplugins.urls,代码行数:26,代码来源:test_web.py
示例4: test_search_html
def test_search_html():
response, content = http.request('http://0.0.0.0:8080/search?q=monkeys')
assert response['status'] == '200', content
assert 'http://fnd.0.0.0.0:8080/One%20Two' in content
assert 'http://cdent.0.0.0.0:8080/three%20two%20one' in content
assert '<a class="space" href="http://fnd.0.0.0.0:8080/">' in content
assert '<img alt="space icon" src="http://fnd.0.0.0.0:8080/SiteIcon"/>' in content
tiddler = store.get(Tiddler('One Two', 'fnd_public'))
tiddler.modifier = 'cowboy'
store.put(tiddler)
response, content = http.request('http://0.0.0.0:8080/search?q=monkeys')
assert response['status'] == '200', content
assert '<a class="modifier" href="http://fnd.0.0.0.0:8080/">' not in content
assert '<a class="modifier" href="http://cowboy.0.0.0.0:8080/">' in content
# tiddlers that do not come from a space should show the default tiddlyspace site icon.
tiddler = Tiddler('commoner', 'common')
tiddler.text = 'I want to live like common people.'
store.put(tiddler)
response, content = http.request('http://0.0.0.0:8080/search?q=title:commoner')
assert response['status'] == '200', content
assert '<img alt="space icon" src="http://0.0.0.0:8080/SiteIcon"/>' in content
开发者ID:Alanchi,项目名称:tiddlyspace,代码行数:28,代码来源:test_search.py
示例5: test_float_field
def test_float_field():
tiddler = Tiddler('foo', 'bar')
tiddler.fields['float'] = 100.5
serializer = Serializer('text')
serializer.object = tiddler
assert '100.5' in '%s' % serializer
开发者ID:24king,项目名称:tiddlyweb,代码行数:7,代码来源:test_tiddler_fields_as_strings.py
示例6: add
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
开发者ID:jdlrobson,项目名称:tiddlyweb,代码行数:25,代码来源:collections.py
示例7: test_call_jsonp
def test_call_jsonp():
"""
test that we can get some stuff as JSONP
"""
tiddler = Tiddler('public')
tiddler.bag = 'foo_public'
tiddler.text = 'some text'
store.put(tiddler)
user_cookie = get_auth('foo', 'foobar')
callback = 'callback'
response, content = http.request('http://foo.0.0.0.0:8080/bags/'
'foo_public/tiddlers/public?callback=%s' % callback,
method='GET',
headers={
'Cookie': 'tiddlyweb_user="%s"' % user_cookie,
'Accept': 'application/json'
})
assert response['status'] == '200'
assert content.startswith('%s(' % callback)
assert content[-1:] == ')'
response, content = http.request('http://0.0.0.0:8080/bags/'
'foo_public/tiddlers/public?callback=%s' % callback,
method='GET',
headers={
'Cookie': 'tiddlyweb_user="%s"' % user_cookie,
'Accept': 'application/json'
})
assert response['status'] == '200'
assert content.startswith('%s(' % callback)
assert content[-1:] == ')'
开发者ID:EnoX1,项目名称:tiddlyspace,代码行数:32,代码来源:test_jsonp.py
示例8: test_hash
def test_hash():
bag = Bag('one')
store.put(bag)
tiddler = Tiddler('hi', 'one')
tiddler.text = 'fancy'
store.put(tiddler)
tiddler = store.get(tiddler)
assert '_hash' in tiddler.fields
response, content = http.request('http://0.0.0.0:8080/bags/one/tiddlers/hi.json',
method='GET')
assert response['status'] == '200'
info = simplejson.loads(content)
assert info['fields']['_hash'] == tiddler.fields['_hash']
info['text'] = 'not fancy'
body = simplejson.dumps(info)
response, content = http.request('http://0.0.0.0:8080/bags/one/tiddlers/hi',
headers={'Content-type': 'application/json'},
body=body,
method='PUT')
assert response['status'] == '204'
tiddler = Tiddler('hi', 'one')
tiddler = store.get(tiddler)
assert tiddler.text == info['text']
assert tiddler.fields['_hash'] != info['fields']['_hash']
开发者ID:EnoX1,项目名称:tiddlyspace,代码行数:32,代码来源:test_put_hash.py
示例9: test_tiddler_full_create
def test_tiddler_full_create():
"""
Confirm we can populate a tiddler at create time.
"""
tiddler = Tiddler('test tiddler')
tiddler.modifier = '[email protected]'
tiddler.text = test_tiddler_text
tiddler.tags = ['foo', 'bar']
tiddler.bag = u'bagone'
assert type(tiddler) == Tiddler, \
'Tiddler returns a Tiddler'
assert tiddler.title == 'test tiddler', \
'tiddler title should be test tiddler, got %s' \
% tiddler.title
assert tiddler.modifier == '[email protected]', \
'tiddler modifier should [email protected], got %s' \
% tiddler.modifier
assert tiddler.text == test_tiddler_text, \
'tiddler content is correct'
assert tiddler.tags == ['foo', 'bar'], \
'tiddler tags are correct'
assert tiddler.bag == 'bagone', \
'tiddler has a bag of bagone'
assert tiddler.revision is None, \
'tiddler revision is None'
assert tiddler.creator == '[email protected]'
开发者ID:tup,项目名称:tiddlyweb,代码行数:28,代码来源:test_tiddler.py
示例10: test_tiddler_put
def test_tiddler_put():
store_root = os.path.join(TMPDIR, "test_store")
bag = Bag("alpha")
tiddler = Tiddler("Foo", bag.name)
tiddler.text = "lorem ipsum\ndolor sit amet"
tiddler.tags = ["foo", "bar"]
STORE.put(bag)
bag_dir = os.path.join(store_root, "bags", "alpha")
assert os.path.isdir(bag_dir)
assert os.path.isdir(os.path.join(bag_dir, "tiddlers"))
STORE.put(tiddler)
tiddler_file = os.path.join(bag_dir, "tiddlers", "Foo")
assert os.path.isfile(tiddler_file)
assert len(tiddler.revision) == 40
with open(tiddler_file) as fh:
contents = fh.read()
assert "tags: foo bar" in contents
assert tiddler.text in contents
info = run("git", "log", "-n1", "--format=%ae %ce: %s", cwd=store_root)
assert info.strip() == "[email protected] [email protected]: tiddler put"
开发者ID:cdent,项目名称:tiddlywebplugins.gitstore,代码行数:25,代码来源:test_tiddler.py
示例11: _process_tiddler_revisions
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
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.atom,代码行数:33,代码来源:feed.py
示例12: test_determine_tiddler_from_recipe
def test_determine_tiddler_from_recipe():
"""
Work out what bag a provided tiddler is in, when we have no knowledge of the bag,
but we do have a recipe.
"""
short_recipe = Recipe(name='foobar')
short_recipe.set_recipe([
[bagone, ''],
[bagfour, 'select=tag:tagone']
])
bag = control.determine_tiddler_bag_from_recipe(short_recipe, tiddlers[0])
assert bag.name == bagfour.name, 'bag name should be bagfour, is %s' % bag.name
short_recipe.set_recipe([
[bagone, ''],
[bagfour, 'select=tag:tagthree']
])
bag = control.determine_tiddler_bag_from_recipe(short_recipe, tiddlers[0])
assert bag.name == bagone.name, 'bag name should be bagone, is %s' % bag.name
lonely_tiddler = Tiddler('lonely')
lonely_tiddler.bag = 'lonelybag'
py.test.raises(NoBagError,
'bag = control.determine_tiddler_bag_from_recipe(short_recipe, lonely_tiddler)')
开发者ID:ingydotnet,项目名称:tiddlyweb,代码行数:25,代码来源:test_recipe.py
示例13: establish_user_auth
def establish_user_auth(config, store, host, username):
user = User(username)
mapping_username = 'github-%s' % username
mapping_tiddler = Tiddler(mapping_username, 'MAPUSER')
mapping_tiddler.fields['mapped_user'] = username
try:
store.delete(user)
except StoreError:
pass
try:
store.delete(mapping_tiddler)
except IOError:
pass
user.add_role('MEMBER')
user.note = '{}'
store.put(user)
ensure_bag('MAPUSER', store)
store.put(mapping_tiddler)
stamp = datetime.utcnow().strftime('%Y%m%d%H')
csrf = gen_nonce(username, host, stamp, config['secret'])
cookie = make_cookie('tiddlyweb_user', mapping_username,
mac_key=config['secret'], httponly=False)
return cookie, csrf
开发者ID:BillSeitz,项目名称:tank,代码行数:26,代码来源:fixtures.py
示例14: manage_gym
def manage_gym(environ, start_response):
store = environ['tiddlyweb.store']
gym = get_route_value(environ, 'gym')
routes_bag = store.get(Bag('%s_climbs' % gym))
news_bag = Bag('%s_news' % gym)
# Bail out if we are not allowed to manage.
routes_bag.policy.allows(environ['tiddlyweb.usersign'], 'manage')
gym_tiddler = store.get(Tiddler(gym, GYMS_BAG))
try:
latest_news = [tiddler for tiddler in filter_tiddlers(
store.list_bag_tiddlers(news_bag),
'sort=-modified;limit=1', environ)][0]
latest_news = store.get(latest_news)
news_html = render_wikitext(latest_news, environ)
latest_news.fields['html'] = news_html
except IndexError:
latest_news = Tiddler('tmp')
latest_news.fields['html'] = '<p>No News</p>'
routes = _get_gym_routes(environ, gym)
return send_template(environ, 'manage_gym.html', {
'title': 'Manage %s' % gym,
'gym_tiddler': gym_tiddler,
'latest_news': latest_news,
'routes': routes})
开发者ID:FND,项目名称:nitor,代码行数:27,代码来源:__init__.py
示例15: test_delete_gets_revisions
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)')
开发者ID:tiddlyweb,项目名称:tiddlywebplugins.caching,代码行数:7,代码来源:test_revisions.py
示例16: submit
def submit(environ, start_response):
"""
Take POSTed input, put it in a Tiddler and save
it into the store, and redirect back to the user
page.
"""
user = environ['tiddlyweb.usersign']['name']
if user == 'GUEST':
raise UserRequiredError, 'real user required to twote'
recent_recipe = _check_recipe('recent', environ, user)
all_recipe = _check_recipe('all', environ, user)
tiddler = _make_tiddler(environ, user)
bag = control.determine_bag_for_tiddler(all_recipe, tiddler)
tiddler.bag = bag.name
store = environ['tiddlyweb.store']
original_title = tiddler.title
tester_tiddler = Tiddler(original_title, bag=bag.name)
addendum = 2
while 1:
try:
tester_tiddler = store.get(tester_tiddler)
new_title = '%s-%s' % (original_title, addendum)
tiddler.title = new_title
tester_tiddler.title = new_title
addendum += 1
except NoTiddlerError:
store.put(tiddler)
break
raise HTTP302, '%s/twoter/%s' % (server_base_url(environ), urllib.quote(user))
开发者ID:moveek,项目名称:tiddlyweb-plugins,代码行数:35,代码来源:twoter.py
示例17: test_web_front
def test_web_front():
bag = Bag('bagone')
store.put(bag)
tiddler = Tiddler('tiddlerone', 'bagone')
tiddler.text = "I am [email protected], http://burningchrome.com/"
store.put(tiddler)
http = httplib2.Http()
response, content = http.request('http://0.0.0.0:8080/bags/bagone/tiddlers/tiddlerone/frontlinks.html')
assert response['status'] == '200', content
assert '<a href="/recipes/cdent_public/tiddlers/NotYou">NotYou</a>' in content, content
bag = Bag('cdent_public')
store.put(bag)
tiddler = Tiddler('NotYou', 'cdent_public')
tiddler.text = 'as BigPoo is'
store.put(tiddler)
response, content = http.request('http://0.0.0.0:8080/bags/cdent_public/tiddlers/NotYou/frontlinks')
assert '<a href="/bags/cdent_public/tiddlers/BigPoo">BigPoo</a>' in content, content
response, content = http.request('http://0.0.0.0:8080/bags/cdent_public/tiddlers/NotYou/backlinks')
assert '<a href="/bags/barney/tiddlers/hello">hello</a>' in content
assert '<a href="/bags/bagone/tiddlers/tiddlerone">tiddlerone</a>' in content
# Use web delete, not store delete as web delete instantiates the tiddler
#store.delete(Tiddler('hello', 'barney'))
response, content = http.request('http://0.0.0.0:8080/bags/barney/tiddlers/hello', method='DELETE')
assert response['status'] == '204'
response, content = http.request('http://0.0.0.0:8080/bags/cdent_public/tiddlers/NotYou/backlinks')
assert '<a href="/bags/barney/tiddlers/hello">hello</a>' not in content
开发者ID:FND,项目名称:tiddlywebplugins.links,代码行数:34,代码来源:test_tiddler.py
示例18: get
def get(environ, start_response):
"""
Using query parameters, determine the current tiddler
and produce an editor for it.
"""
usersign = environ['tiddlyweb.usersign']
try:
tiddler_name = environ['tiddlyweb.query'].get('tiddler', [''])[0]
recipe_name = environ['tiddlyweb.query'].get('recipe', [''])[0]
bag_name = environ['tiddlyweb.query'].get('bag', [''])[0]
#tiddler_name = unicode(urllib.unquote(tiddler_name), 'utf-8')
#bag_name = unicode(urllib.unquote(bag_name), 'utf-8')
#recipe_name = unicode(urllib.unquote(recipe_name), 'utf-8')
except (KeyError, IndexError):
raise HTTP400('tiddler, recipe and bag query strings required')
store = environ['tiddlyweb.store']
tiddler = Tiddler(tiddler_name)
if bag_name:
tiddler.bag = bag_name
else:
recipe = Recipe(recipe_name)
try:
recipe = store.get(recipe)
tiddler.bag = control.determine_tiddler_bag_from_recipe(recipe, tiddler).name
tiddler.recipe = recipe.name
except NoRecipeError, exc:
raise HTTP404('unable to edit %s, recipe %s not found: %s' % (tiddler.title, recipe_name, exc))
except NoBagError, exc:
raise HTTP404('unable to edit %s: %s' % (tiddler.title, exc))
开发者ID:FND,项目名称:tiddlywiki-svn-mirror,代码行数:31,代码来源:tiddlywebeditor_plus.py
示例19: test_simple_spacelink
def test_simple_spacelink():
tiddler = Tiddler('test')
tiddler.text = '# Hi\nVisit @cdent for more info.'
output = render(tiddler, environ)
assert '<a href="http://cdent.tiddlyspace.org:8080/">@cdent</a>' in output
开发者ID:FND,项目名称:tiddlywebplugins.markdown,代码行数:7,代码来源:test_spacelinks.py
示例20: test_search_unique
def test_search_unique():
bag = Bag('bag1')
store.put(bag)
tiddler1 = Tiddler('tiddler1', 'bag1')
tiddler1.text = 'catsdogshouses'
store.put(tiddler1)
tiddler2 = Tiddler('tiddler2', 'bag1')
tiddler2.text = 'housesdogscats'
store.put(tiddler2)
tiddlers = list(search(config, 'catsdogshouses'))
assert len(tiddlers) == 1
assert tiddlers[0]['id'] == 'bag1:tiddler1'
tiddlers = list(search(config, 'housesdogscats'))
assert len(tiddlers) == 1
assert tiddlers[0]['id'] == 'bag1:tiddler2'
store.delete(tiddler1)
tiddlers = list(search(config, 'catsdogshouses'))
assert len(tiddlers) == 0
tiddlers = list(search(config, 'housesdogscats'))
assert len(tiddlers) == 1
assert tiddlers[0]['id'] == 'bag1:tiddler2'
store.delete(tiddler2)
tiddlers = list(search(config, 'housesdogscats'))
assert len(tiddlers) == 0
开发者ID:jdlrobson,项目名称:tiddlyweb-plugins,代码行数:32,代码来源:test_delete.py
注:本文中的tiddlyweb.model.tiddler.Tiddler类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论