def instancer(environ, start_response): store = environ['tiddlyweb.store'] recipe_id = environ['tiddlyweb.query']['submit'][0] bag_id = recipe_id + '.' + str(uuid()) ensure_bag(bag_id, store) template = template_env.get_template('instance.html') return template.generate(recipe=recipe_id, url=_url_from_bag_id(environ, bag_id))
def _user_form_bag(store, username, form_id): """ Ensure a bag exists for this user's use of this form. """ policy_dict = { 'read': [username, 'R:ADMIN'], 'write': [username, 'R:ADMIN'], 'create': [username, 'R:ADMIN'], 'delete': [username, 'R:ADMIN'], } name = sha(form_id + username).hexdigest() return ensure_bag(name, store, policy_dict=policy_dict, owner=username)