I have a preliminary version of inclusion if T2 functionality into
web2py core. I am not yet promising backward compatibility here. The
module name many change. For now it is in trunk as gluon/utils.py
Here is how you use it (assuming [app] is you application name).
1) put this in your model
from gluon.utils import *
auth=Auth(globals(),db)
auth.define_tables()
crud=Crud(globals(),db)
2) put this in your "default" controller
def user(): return dict(form=auth())
def database(): return dict(form=crud())
def download(): return response.download()
def index():
response.flash=T('Welcome to web2py')
return dict(message=T('Hello World'))
Now visit:
http://..../[app]/default/user/register
http://..../[app]/default/user/login
http://..../[app]/default/user/profile
http://..../[app]/default/user/change_password
http://..../[app]/default/user/groups
http://..../[app]/default/user/logout
http://..../[app]/default/user/retrieve_password
http://..../[app]/default/database/tables
http://..../[app]/default/database/select/[app]_event
http://..../[app]/default/database/create/[app]_event
http://..../[app]/default/database/read/[app]_event/1
http://..../[app]/default/database/update/[app]_event/1
http://..../[app]/default/database/delete/[app]_event/1
now add to the model
mail=Mail()
mail.settings.server='smtp.whetever.com'
mail.settings.sender='[email protected]'
mail.settings.longin='username:password'
auth.settings.mail=mail
so that registration requires email verification
then add
auth.settings.captcha=RECAPTCHA
(request,public_key='RECAPTCHA_PUBLIC_KEY',private_key='RECAPTCHA_PRIVATE_KEY')
so that registration will use recaptcha
then add
crud.auth=auth
so that crud will enforce role based access control....
now you lost the permission to access http://.../database/....
now give yourself back permission *only* to select record in table
[app]_user
group_id=auth.add_group(role='Manager')
auth.add_membership(group_id,auth.user.id)
auth.add_permission(group_id,'select','[app]_user')
or to delete users
auth.add_permission(group_id,'delete','[app]_user')
get the idea?.... I think I have been following (or tried to) the
advice of some of the members here like Yarko, Ceej, Bill, Fran, and
others.
There is a lot more stuff in there (like decorators that enforce
permissions) that needs polishing and documenting.
Volunteers to help?
Massimo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---