Hi Bruno, I have been looking at your code. How would you override the Auth to not include first name last name using your class?
IE: How would we do the following using your approach? (BaseAuth) db.define_table( auth.settings.table_user_name, Field('username', length=128, default='0000000', unique=True), Field('account_id', db.user_account), Field('email', length=128, default=''), Field('password', 'password', length=512, readable=False, label='Password'), Field('security', 'password', length=512, readable=False, label='Security Password'), Field('registration_key', length=512, writable=False, readable=False, default=''), Field('reset_password_key', length=512, writable=False, readable=False, default=''), Field('reset_security_key', length=512, writable=False, readable=False, default=''), Field('registration_id', length=512, writable=False, readable=False, default='') ) custom_auth_table = db[auth.settings.table_user_name] # get the custom_auth_table custom_auth_table.password.requires = [IS_STRONG(), CRYPT()] custom_auth_table.security.requires = [IS_STRONG(), CRYPT()] custom_auth_table.email.requires = [ IS_EMAIL(error_message=auth.messages.invalid_email), IS_NOT_IN_DB(db, custom_auth_table.email)] auth.settings.table_user = custom_auth_table auth.define_tables() -- Regards, Bruce On Mon, Jan 30, 2012 at 6:24 AM, Ross Peoples <ross.peop...@gmail.com>wrote: > Bruno, > > This is a good article. I have done something like this before. My > approach was a bit different. I was using the singleton pattern, but I > think it accomplishes the same goal. > > I would for example have a module like this: > > from gluon import * > > class MyModel(object): > instance = None > > def get(db): > if instance is None: > instance = MyModel(db) > > return instance > > def __init__(self, db): > db.define_table(....) > > > Then I would still have a db.py for a model, but I would replace the usual > db.define_table() with this: > > from mymodel import MyModel > MyModel.get(db) > > This ensures that the tables only get defined once on the first request > after starting web2py. I have used this approach on other code that I > needed to keep alive for other requests. > -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com