I am reposting this because I renamed the file

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.tools import *   ###### <- this was utils.py now it is
tools.py
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 data(): return dict(form=crud())
def download(): return response.download(request,db)

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/data/tables
http://..../[app]/default/data/select/[app]_event
http://..../[app]/default/data/create/[app]_event
http://..../[app]/default/data/read/[app]_event/1
http://..../[app]/default/data/update/[app]_event/1
http://..../[app]/default/data/delete/[app]_event/1

now add to the model

mail=Mail()
mail.settings.server='smtp.whetever.com'
mail.settings.sender='....@whatever.com'
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.

This is not yet the end of the story but if you need Auth, Crud, you
can start using these.

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 web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to