Beispiel #1
0
def index(type_name):
    """ Index all entities of a given type. """
    type_ = Type.by_name(type_name)
    if type_ is None:
        print "No such type: %s" % type_name
    else:
        type_.index()
Beispiel #2
0
def entity(type, key, format=None):
    type_ = Type.by_name(type)
    if type_ is None:
        abort(404)
    entity = type_.by_key(key)
    if entity is None:
        abort(404)
    del entity['__id__']
    url = url_for('entity', type=type, key=key, _external=True)
    format = request_format(format)
    if format == 'json':
        entity['_url'] = url
        return jsonify(entity)
    #if 'redirect_url' in entity:
    #    return redirect(entity.get('redirect_url'),
    #                    code=303)
    return render_template('view.tmpl', entity=entity, url=url)