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/9261e53e-d45b-4be1-82e8-2d19a488df78%40googlegroups.com.