How to use the py4web.action 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 / apps / todo / __init__.py View on Github external
@action.requires(user_in(session))
@action.uses(db)
def todo(id):
    db(db.todo.id == id).delete()
    return dict()
github web2py / py4web / apps / todo / __init__.py View on Github external
@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("api/", method="DELETE")
@action.uses(session)
@action.requires(user_in(session))
@action.uses(db)
def todo(id):
    db(db.todo.id == id).delete()
    return dict()
github web2py / py4web / apps / examples / controllers.py View on Github external
@action("index")
@action.uses("index.html")
def index():
    return {}
github web2py / py4web / apps / examples / controllers.py View on Github external
@action("hello")
@action.uses(T)
def hello():
    return str(T("Hello World"))
github web2py / py4web / apps / _dashboard / __init__.py View on Github external
    @action("index")
    @action.uses("index.html", session, T)
    def index():
        return dict(
            languages=dumps(T.local.language),
            mode=MODE,
            user_id=(session.get("user") or {}).get("id"),
        )
github web2py / py4web / apps / myapp / controllers.py View on Github external
@action.uses(db, 'helloworld.html')
def helloworld(): return dict(name=request.forms.get('name', 'visitor'))
github web2py / py4web / apps / _dashboard / __init__.py View on Github external
    @action("logout", method="POST")
    @action.uses(session)
    def logout():
        session["user"] = None
        return dict()
github web2py / py4web / apps / examples / controllers.py View on Github external
@action("create_form", method=["GET", "POST"])
@action("update_form/", method=["GET", "POST"])
@action.uses("form.html", db, session, T)
def example_form(id=None):
    form = Form(db.person, id, deletable=False, formstyle=FormStyleBulma)
    rows = db(db.person).select()
    return dict(form=form, rows=rows)
github web2py / py4web / py4web / utils / publisher.py View on Github external
def __init__(self, db, policy=None, auth=None, path="service/{uuid}/"):
        self.db = db
        self.policy = policy
        self.restapi = RestAPI(self.db, policy)
        self.path = path.format(uuid=str(uuid.uuid4()))
        args = [db, auth] if auth else [db]
        f = action.uses(*args)(self.api)
        f = action(self.path, method=["GET", "POST"])(f)
        f = action(self.path + "/", method=["PUT", "DELETE"])(f)