Hi,

I'm attempting to use Auth to create a custom form.  Working on
piecing together the examples from the wiki and from postings on the
web2py Web Framework group.

Here's the progress so far:

1.  Got the code below to work except for the section marked
"#Define"  which ends with "#End of Define" code below.  I get an
error that auth2 is undefined. The question is:  How do I define
additional fields using this code?  Am I getting an interference with
email_auth?

2.  After #1 above is completed, how do I create a custom form?
Specifically, how do I reference the table defined in #1 above?  Does
this process occur in the function:  "def user(): return dict
(form=auth2())" or do you create views for each one of the calls to
Auth?  For example, "/default/user/login" or "/default/user/register"
etc?

try:
    from gluon.contrib.gql import *
    db=GQLDB()
    session.connect(request,response,db=db)
    except:
    db=SQLDB()


from gluon.tools import Mail, Auth, geocode
from gluon.contrib.login_methods.email_auth import email_auth


class GuestBookAuth(Auth):
    def __init__(self, environment, T, db = None):
       Auth.__init__(self, environment, db)
       self.messages.logged_in = T("Logged in")
       self.messages.email_sent = T("Email sent")
       self.messages.email_verified = T("Email verified")
       self.messages.logged_out = T("Logged out")
       self.messages.registration_successful = T("Registration
successful")
       self.messages.invalid_email = T("Invalid email")
       self.messages.invalid_login = T("Invalid login")
       self.messages.verify_email_subject = T("Password verify")
       self.messages.username_sent = T("Your username was emailed to
you")
       self.messages.new_password_sent = T("A new password was emailed
to you")
       self.messages.password_changed = T("Password changed")
       self.messages.retrieve_username = str(T("Your username is"))+":
% (username)s"
       self.messages.retrieve_username_subject = T("Username
retrieve")
       self.messages.retrieve_password = str(T("Your password is"))+":
% (password)s"
       self.messages.retrieve_password_subject = T("Password
retrieve")
       self.messages.profile_updated = T("Profile updated")

auth2=GuestBookAuth(globals(), T, db)

#Define

auth2.settings.table_user = db.define_table(
        self.settings.table_user_name,
            db.Field('first_name', length=128,default=''),
            db.Field('last_name', length=128,default=''),
            db.Field('email', length=128,default=''),
            db.Field('password', 'password',
readable=False,label='Password'),
            db.Field('registration_key', length=128, writable=False,
readable=False,default=''))
        table = auth2.settings.table_user
        table.first_name.requires = IS_NOT_EMPTY()
        table.last_name.requires = IS_NOT_EMPTY()
        table.password.requires = CRYPT()
        table.email.requires = [IS_EMAIL(), IS_NOT_IN_DB(db,
'%s.email' % self.settings.table_user._tablename)]


#End of Define


auth2.settings.login_methods.append(email_auth())

auth2.define_tables()

#controller
def user(): return dict(form=auth2())
--~--~---------~--~----~------------~-------~--~----~
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