예제 #1
0
def main():
    template_root = join(dirname(realpath(__file__)), 'templates')

    DB_CONNECTION.connect()

    DB_CONNECTION.create_tables((Record, ), safe=True)

    Record.delete().execute()
    Record.insert_many(({} for _ in range(500))).execute()

    DB_CONNECTION.close()

    DB_CONNECTION.set_allow_sync(False)

    try:
        application = Application()
        jinja2_setup(application, loader=FileSystemLoader(template_root))

        application.router.add_get('/', raw_response_handle)
        application.router.add_get('/template', html_response_handle)
        application.router.add_get('/database', database_response_handle)
        application.router.add_get('/service', service_response_handle)

        run_app(application)
    except Exception as exception:
        # TODO: error notification logic
        raise exception
    finally:
        DB_CONNECTION.close()
예제 #2
0
파일: views.py 프로젝트: HardBite/flibr
def delete(instance, obj_id):
    obj = Record().give_child(instance)
    obj = obj.get_by_id_or_new(obj_id)
    obj.delete()
    if not request.is_xhr:
        return redirect('index/'+repr(obj))
    else:
        return "it ok"
예제 #3
0
def delete(record_id):
    Record.delete(record_id)
    return '1'