Example #1
0
def bag_favor(environ, start_response):
    user = get_user_object(environ)
    store = environ['tiddlyweb.store']
    ensure_user_bag(store, user['name'])
    new_favorite = environ['tiddlyweb.query'].get('bag', [''])[0]
    favorites = get_favorites(store, user['name'])
    # XXX I suppose a set would be okay here.
    if new_favorite and new_favorite not in favorites:
        favorites.append(new_favorite)
    tiddler = store.get(Tiddler('favorites', user['name']))
    tiddler.text = '\n'.join(favorites)
    store.put(tiddler)
    raise HTTP303('%s/home' % server_base_url(environ))
Example #2
0
def bag_favor(environ, start_response):
    user = get_user_object(environ)
    store = environ["tiddlyweb.store"]
    ensure_user_bag(store, user["name"])
    new_favorite = environ["tiddlyweb.query"].get("bag", [""])[0]
    favorites = get_favorites(store, user["name"])
    # XXX I suppose a set would be okay here.
    if new_favorite and new_favorite not in favorites:
        favorites.append(new_favorite)
    tiddler = Tiddler("favorites", user["name"])
    try:
        tiddler = store.get(tiddler)
    except NoTiddlerError:
        pass  # is okay if tiddler doesn't exist yet
    tiddler.text = "\n".join(favorites)
    store.put(tiddler)
    raise HTTP303("%s/home" % server_base_url(environ))
Example #3
0
def bag_favor(environ, start_response):
    user = get_user_object(environ)
    store = environ['tiddlyweb.store']
    ensure_user_bag(store, user['name'])
    new_favorite = environ['tiddlyweb.query'].get('bag', [''])[0]
    favorites = get_favorites(store, user['name'])
    # XXX I suppose a set would be okay here.
    if new_favorite and new_favorite not in favorites:
        favorites.append(new_favorite)
    tiddler = Tiddler('favorites', user['name'])
    try:
        tiddler = store.get(tiddler)
    except NoTiddlerError:
        pass  # is okay if tiddler doesn't exist yet
    tiddler.text = '\n'.join(favorites)
    tiddler.modifier = user['name']
    store.put(tiddler)
    raise HTTP303('%s/home' % server_base_url(environ))
Example #4
0
def bag_favor(environ, start_response):
    user = get_user_object(environ)
    store = environ['tiddlyweb.store']
    ensure_user_bag(store, user['name'])
    new_favorite = environ['tiddlyweb.query'].get('bag', [''])[0]
    favorites = get_favorites(store, user['name'])
    # XXX I suppose a set would be okay here.
    if new_favorite and new_favorite not in favorites:
        favorites.append(new_favorite)
    tiddler = Tiddler('favorites', user['name'])
    try:
        tiddler = store.get(tiddler)
    except NoTiddlerError:
        pass # is okay if tiddler doesn't exist yet
    tiddler.text = '\n'.join(favorites)
    tiddler.modifier = user['name']
    store.put(tiddler)
    raise HTTP303('%s/home' % server_base_url(environ))