What do @authenticated and @unauthenticated do?
Can they be added to the documentation?
In particular I don't understand
# define a button that make the following serverside POST callback
@unauthenticated.button("click me")
def a_button(msg):
print("you clicked the button and server received:", msg)
Thanks!
Luca
Luca
On Friday, January 31, 2020 at 8:55:11 PM UTC-8, Massimo Di Pierro wrote:
>
> I committed some new code to py4web
>
> Now you can do:
>
> from . common import authenticated, unauthenticated # from latest _scaffold
>
> # exposes index as /{app_name}/index and uses index.html or generic.html
> template, auth.user, db, T, session
> @authenticated()
> def index():
> return dict()
>
> # GET only
> @authenticated.get()
> def index():
> return dict()
>
> # exposes /{app_name}/index/<a>/<b>/<c>
> @authenticated.get()
> def index(a,b,c):
> return dict()
>
> # more explicit
> @authenticated.get("index/<a:int>/<b:int>/<c:re:.*>)
> def index(a,b,c):
> return dict()
>
> Some magic
>
> # define a button that make the following serverside POST callback
> @unauthenticated.button("click me")
> def a_button(msg):
> print("you clicked the button and server received:", msg)
>
> # expose a page that displays the button which - onclick - makes the
> ballback
> @unauthenticated.get()
> def show_a_button():
> return dict(mybutton = a_button(msg="hello world"))
>
> Thoughts? Should we keep this API? Can we improve it?
>
>
>
>
>
>
>
>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/7b38abbe-3a07-41c1-9402-0204edf1e12d%40googlegroups.com.