[web2py] Re: proper way to define a user table
On Aug 1, 9:10 am, Anthony wrote: > On Monday, August 1, 2011 6:23:03 AM UTC-4, Ramos wrote: > > > this way works > > > auth.settings.extra_fields['auth_user'] = [Field('Skype')] > > Yes, this will create auth.settings.extra_fields['auth_user']. Once created, > you should be able to add additional fields via append(). > > Anthony If you are trying to append to a list, or create it if it's not present, don't you want to do it this way? try: auth.settings.extra_fields['auth_user'].append(Field('Skype')) except: auth.settings.extra_fields['auth_user'] = [Field('Skype')] Rufus
Re: [web2py] Re: proper way to define a user table
On Monday, August 1, 2011 6:23:03 AM UTC-4, Ramos wrote: > > this way works > > auth.settings.extra_fields['auth_user'] = [Field('Skype')] > Yes, this will create auth.settings.extra_fields['auth_user']. Once created, you should be able to add additional fields via append(). Anthony
Re: [web2py] Re: proper way to define a user table
this way works auth.settings.extra_fields['auth_user'] = [Field('Skype')] Em 1 de agosto de 2011 10:46, António Ramos escreveu: > i tried but got this error > > > File "gluon/restricted.py", line 192, in restricted > File "D:/web2py10/web2py/applications/Vendas/models/db.py", line 55, in > > KeyError: 'auth_user' > > the line 55 is > *auth.settings.extra_fields['auth_user'].append(Field('Skype')) * > > > 2011/7/30 pbreit > >> auth.settings.extra_fields['auth_user'].append(Field('country')) > > >
Re: [web2py] Re: proper way to define a user table
i tried but got this error File "gluon/restricted.py", line 192, in restricted File "D:/web2py10/web2py/applications/Vendas/models/db.py", line 55, in KeyError: 'auth_user' the line 55 is *auth.settings.extra_fields['auth_user'].append(Field('Skype')) * 2011/7/30 pbreit > auth.settings.extra_fields['auth_user'].append(Field('country'))
[web2py] Re: proper way to define a user table
Also, "extra_fields" was recently added: - 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()
[web2py] Re: proper way to define a user table
Why dont you do something like this? auth.settings.extra_fields['auth_user'].append(Field('country')) to add a "country" field to the user table On Jul 29, 6:06 pm, Anthony wrote: > On Friday, July 29, 2011 12:49:46 PM UTC-4, Ramos wrote: > > > do i need this line > > auth.define_tables() > > Yes, that should come after you define your custom table(s) -- it defines > any Auth tables that have not already been defined (using default table > definitions). > > Anthony
Re: [web2py] Re: proper way to define a user table
On Friday, July 29, 2011 12:49:46 PM UTC-4, Ramos wrote: > > do i need this line > auth.define_tables() > Yes, that should come after you define your custom table(s) -- it defines any Auth tables that have not already been defined (using default table definitions). Anthony
Re: [web2py] Re: proper way to define a user table
do i need this line auth.define_tables() ? 2011/7/29 Anthony > Not sure. > > On Friday, July 29, 2011 12:03:44 PM UTC-4, Ramos wrote: > >> oops again >> i just lost all tables >> >> groups,membership,etc >> >> why? >> >> 2011/7/29 Anthony >> >> Oops, the printed book is wrong -- see the corrected version here: >>> http://web2py.com/book/default/chapter/08#Customizing-Auth. >>> >>> Anthony >>> >>> On Friday, July 29, 2011 11:29:35 AM UTC-4, Ramos wrote: >>> i need to add one more field in my auth table: in reading the book on page 358 and 259 I´m not geting it to work i get error , auth_table not defined. 1 # after 2 # auth = Auth(globals(),db) 3 4 db.define_table( 5 auth.settings.table_user_name, 6 Field('first_name', length=128, default=''), 7 Field('last_name', length=128, default=''), 8 Field('email', length=128, default='', unique=True), 9 Field('password', 'password', length=512, 10 readable=False, label='Password'), 11 Field('registration_key', length=512, 12 writable=False, readable=False, default=''), 13 Field('reset_password_key', length=512, 14 writable=False, readable=False, default=''), 15 Field('registration_id', length=512, 16 writable=False, readable=False, default='')) 17 18 auth_table.first_name.requires = \ 19 IS_NOT_EMPTY(error_message=auth.messages.is_empty) 20 auth_table.last_name.requires = \ 21 IS_NOT_EMPTY(error_message=auth.messages.is_empty) 22 auth_table.password.requires = [IS_STRONG(), CRYPT()] 23 auth_table.email.requires = [ 24 IS_EMAIL(error_message=auth.messages. before 26 auth.settings.table_user = auth_table 27 28 # before 29 # auth.define_tables() >>> >>
Re: [web2py] Re: proper way to define a user table
Not sure. On Friday, July 29, 2011 12:03:44 PM UTC-4, Ramos wrote: > oops again > i just lost all tables > > groups,membership,etc > > why? > > 2011/7/29 Anthony > >> Oops, the printed book is wrong -- see the corrected version here: >> http://web2py.com/book/default/chapter/08#Customizing-Auth. >> >> Anthony >> >> On Friday, July 29, 2011 11:29:35 AM UTC-4, Ramos wrote: >> >>> i need to add one more field in my auth table: >>> >>> in reading the book on page 358 and 259 >>> >>> I´m not geting it to work >>> i get error , auth_table not defined. >>> >>> >>> >>> 1 # after >>> 2 # auth = Auth(globals(),db) >>> 3 >>> 4 db.define_table( >>> 5 auth.settings.table_user_name, >>> 6 Field('first_name', length=128, default=''), >>> 7 Field('last_name', length=128, default=''), >>> 8 Field('email', length=128, default='', unique=True), >>> 9 Field('password', 'password', length=512, >>> 10 readable=False, label='Password'), >>> 11 Field('registration_key', length=512, >>> 12 writable=False, readable=False, default=''), >>> 13 Field('reset_password_key', length=512, >>> 14 writable=False, readable=False, default=''), >>> 15 Field('registration_id', length=512, >>> 16 writable=False, readable=False, default='')) >>> 17 >>> 18 auth_table.first_name.requires = \ >>> 19 IS_NOT_EMPTY(error_message=auth.messages.is_empty) >>> 20 auth_table.last_name.requires = \ >>> 21 IS_NOT_EMPTY(error_message=auth.messages.is_empty) >>> 22 auth_table.password.requires = [IS_STRONG(), CRYPT()] >>> 23 auth_table.email.requires = [ >>> 24 IS_EMAIL(error_message=auth.messages. >>> >>> >>> before >>> 26 auth.settings.table_user = auth_table >>> 27 >>> 28 # before >>> 29 # auth.define_tables() >>> >> >
Re: [web2py] Re: proper way to define a user table
oops again i just lost all tables groups,membership,etc why? 2011/7/29 Anthony > Oops, the printed book is wrong -- see the corrected version here: > http://web2py.com/book/default/chapter/08#Customizing-Auth. > > Anthony > > On Friday, July 29, 2011 11:29:35 AM UTC-4, Ramos wrote: > >> i need to add one more field in my auth table: >> >> in reading the book on page 358 and 259 >> >> I´m not geting it to work >> i get error , auth_table not defined. >> >> >> >> 1 # after >> 2 # auth = Auth(globals(),db) >> 3 >> 4 db.define_table( >> 5 auth.settings.table_user_name, >> 6 Field('first_name', length=128, default=''), >> 7 Field('last_name', length=128, default=''), >> 8 Field('email', length=128, default='', unique=True), >> 9 Field('password', 'password', length=512, >> 10 readable=False, label='Password'), >> 11 Field('registration_key', length=512, >> 12 writable=False, readable=False, default=''), >> 13 Field('reset_password_key', length=512, >> 14 writable=False, readable=False, default=''), >> 15 Field('registration_id', length=512, >> 16 writable=False, readable=False, default='')) >> 17 >> 18 auth_table.first_name.requires = \ >> 19 IS_NOT_EMPTY(error_message=auth.messages.is_empty) >> 20 auth_table.last_name.requires = \ >> 21 IS_NOT_EMPTY(error_message=auth.messages.is_empty) >> 22 auth_table.password.requires = [IS_STRONG(), CRYPT()] >> 23 auth_table.email.requires = [ >> 24 IS_EMAIL(error_message=auth.messages. >> >> >> before >> 26 auth.settings.table_user = auth_table >> 27 >> 28 # before >> 29 # auth.define_tables() >> >
[web2py] Re: proper way to define a user table
Oops, the printed book is wrong -- see the corrected version here: http://web2py.com/book/default/chapter/08#Customizing-Auth. Anthony On Friday, July 29, 2011 11:29:35 AM UTC-4, Ramos wrote: > i need to add one more field in my auth table: > > in reading the book on page 358 and 259 > > I´m not geting it to work > i get error , auth_table not defined. > > > > 1 # after > 2 # auth = Auth(globals(),db) > 3 > 4 db.define_table( > 5 auth.settings.table_user_name, > 6 Field('first_name', length=128, default=''), > 7 Field('last_name', length=128, default=''), > 8 Field('email', length=128, default='', unique=True), > 9 Field('password', 'password', length=512, > 10 readable=False, label='Password'), > 11 Field('registration_key', length=512, > 12 writable=False, readable=False, default=''), > 13 Field('reset_password_key', length=512, > 14 writable=False, readable=False, default=''), > 15 Field('registration_id', length=512, > 16 writable=False, readable=False, default='')) > 17 > 18 auth_table.first_name.requires = \ > 19 IS_NOT_EMPTY(error_message=auth.messages.is_empty) > 20 auth_table.last_name.requires = \ > 21 IS_NOT_EMPTY(error_message=auth.messages.is_empty) > 22 auth_table.password.requires = [IS_STRONG(), CRYPT()] > 23 auth_table.email.requires = [ > 24 IS_EMAIL(error_message=auth.messages. > > > before > 26 auth.settings.table_user = auth_table > 27 > 28 # before > 29 # auth.define_tables() >