On 17/06/2011 15:58, Anthony wrote:
On Friday, June 17, 2011 9:38:09 AM UTC-4, Manuele wrote:

    is there a way to add just a single field to the user table without
    re-wrintig a customized version as explained in

    http://www.web2py.com/book/default/chapter/08#Customizing-Auth
    <http://www.web2py.com/book/default/chapter/08#Customizing-Auth>

    I mean... if I only want to add "username" field in order to use it in
    place of email during user login... how can I do it? if I can...

Specifically for adding a username field to to be used for login, you
can do:
auth.define_tables(username=True)
See http://web2py.com/book/default/chapter/08#Authentication.
More generally, as of 1.96.1, you can add custom fields to any auth
table with:
auth.settings.extra_fields['auth_table_name_goes_here'].append(Fields('new_field_name',...))
Anthony

found this feature that you cite:

http://www.web2py.com/examples/default/changelog

'''
auth.settings.extra_fields['auth_user'].append(Field('country')) allows to extend auth_* tables without need of definiting a custom auth_* table. Must be placed before auth.define_tables()
'''

but applied as written I got a KeyError: 'auth_user'. I thik I have correcly applied as reported here under (I'm using a 1.96.4 version)

...
auth.define_tables(username=True)
auth.settings.extra_fields['auth_user'].append(
    Fields('company', db.company, required=True, notnull=True,
        requires=IS_IN_DB(db, 'company.id', '%(name)s'))
)
auth.define_tables()    # creates all needed tables
...

thanks

        Manuele

Reply via email to