How to use the py4web.action.requires function in py4web

To help you get started, we’ve selected a few py4web examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github web2py / py4web / tests / test_action.py View on Github external
@action.requires(lambda: True)
def index():
    db.thing.insert(name="test")
    session["number"] = session.get("number", 0) + 1
    return "ok %s %s" % (session["number"], db(db.thing).count())
github web2py / py4web / apps / todo / __init__.py View on Github external
@action.requires(user_in(session))
@action.uses(db)
def todo():
    return dict(id=db.todo.insert(info=request.json.get("info")))
github web2py / py4web / apps / todo / __init__.py View on Github external
@action.requires(user_in(session))  # then check we have a valid user in session
@action.uses(db)  # all before starting a db connection
def todo():
    return dict(items=db(db.todo).select(orderby=~db.todo.id).as_list())