Yes, seems like a bug. I guess no one uses this setting (probably because it's not documented).
Anthony On Sunday, April 6, 2014 3:02:41 PM UTC-4, Ray (a.k.a. Iceberg) wrote: > > > On Sunday, April 6, 2014 12:03:59 AM UTC-7, Ray (a.k.a. Iceberg) wrote: >> >> Just want to double confirm. >> >> 1. I found many following lines in tools.py: >> >> userfield = self.settings.login_userfield or 'username' \ >> if 'username' in table_user.fields else 'email' >> >> it means: >> >> if 'username' in table_user.fields: >> userfield = self.settings.login_userfield or 'username' >> else: >> userfield = 'email >> >> >> 2. If we used a slightly different source code like this: >> >> userfield = self.settings.login_userfield or ('username' >> if 'username' in table_user.fields else 'email') >> >> it means something quite different: >> >> if self.settings.login_userfield: # if user explicitly define >> the login_userfield >> userfield = self.settings.login_userfield # then use it >> unconditionally >> else: # otherwise automatically determine one >> userfield = 'username' if 'username' in table_user.fields >> else 'email' >> >> >> So, to double confirm, what is the design purpose of >> auth.settings.login_userfield? If it is #1, I recommend to use a pair of >> brackets to avoid misunderstanding. >> >> userfield = (self.settings.login_userfield or 'username' >> ) if 'username' in table_user.fields else 'email' >> >> > Well, now I believe the #2 purpose is the design intention, based on this > section in Auth.register(): > > table_user = self.table_user() > if self.settings.login_userfield: > username = self.settings.login_userfield > elif 'username' in table_user.fields: > username = 'username' > else: > username = 'email' > > In this case, I believe #1 is a bug and need to be fixed. > -- 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.