Yes, as I mentioned, because you cannot set db.auth_user._format before 
defining the other tables, you instead have to explicitly change the 
"represent" and "requires" attributes of the other tables after they have 
been defined. We should probably add a setting for db.auth_user._format to 
avoid this problem.

Anthony

On Monday, April 6, 2015 at 12:41:37 AM UTC-4, 黄祥 wrote:
>
> yes, you are right, i defined the custom_auth after auth.define_tables(), 
> but the problem is when i put it before auth.define_tables() it return an 
> error
> *e.g. no error but the result is not expected*
> auth = Auth(db)
>
> audit_from = db.Table(db, 'audit_from',
>     Field('created_from', default = request.client, readable = False, 
> writable = False),
>     Field('modified_from', update = request.client, readable = False, 
> writable = False) )
>
> db._common_fields.append(audit_from)
>
> auth.define_tables(username = True, signature = True)
>
> custom_auth_table = db[auth.settings.table_user_name]
>
> custom_auth_table._format = '%(first_name)s %(last_name)s'
> custom_auth_table.first_name.label = T('First Name')
> custom_auth_table.last_name.label = T('Last Name')
> custom_auth_table.email.label = T('Email')
>
> auth.settings.table_user = custom_auth_table
>
> *e.g. error occured*
> auth = Auth(db)
>
> audit_from = db.Table(db, 'audit_from',
>     Field('created_from', default = request.client, readable = False, 
> writable = False),
>     Field('modified_from', update = request.client, readable = False, 
> writable = False) )
>
> db._common_fields.append(audit_from)
>
> custom_auth_table = db[auth.settings.table_user_name]
>
> custom_auth_table._format = '%(first_name)s %(last_name)s'
> custom_auth_table.first_name.label = T('First Name')
> custom_auth_table.last_name.label = T('Last Name')
> custom_auth_table.email.label = T('Email')
>
> auth.settings.table_user = custom_auth_table
>
> auth.define_tables(username = True, signature = True)
>
> *error*
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 227, in restricted
>     exec ccode in environment
>   File "C:/web2py/applications/hostel/models/db.py" 
> <https://127.0.0.1/admin/default/edit/hostel/models/db.py>, line 42, in 
> <module>
>     custom_auth_table = db[auth.settings.table_user_name]
>   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 922, in __getitem__
>     return self.__getattr__(str(key))
>   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 929, in __getattr__
>     return ogetattr(self, key)
> AttributeError: 'DAL' object has no attribute 'auth_user'
>
>
> what i want to achieve is the auth_user table format representation can be 
> shown in another auth tables (auth_event and auth membership). how can i 
> solve this using web2py way?
>
> thanks and best regards,
> stifan
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to