fixed in trunk
On Sep 20, 10:07 am, "dustin.b" <dustin.bens...@googlemail.com> wrote: > hi i simply upgraded from 1.84.1 to 1.85.1 and get a ticket. i > narrowed down the issue to this: > > db.py > .... > > auth.settings.hmac_key = 'sha512:97655ab8-04d0-4321- > b8fa-84f525fb8fe0' # before define_tables() > > db.define_table( > auth.settings.table_user_name, > Field('username', length=128, default='', unique=True), > > Field('password', 'password', length=512, > readable=False, label='Password'), > Field('registration_key', length=512, > writable=False, readable=False, default=''), > Field('reset_password_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.username.requires = > IS_NOT_EMPTY(error_message=auth.messages.is_empty) > > #custom_auth_table.password.requires = [IS_STRONG(), CRYPT()] > > auth.settings.table_user = custom_auth_table # tell auth to use > custom_auth_tabl > > auth.define_tables() # creates all needed > tables > ..... > > test.py (controller) > .... > def myLogin(): > > username = "peter" > password = "pass" > > user = auth.login_bare(username, password) > if not user: > return "failed" > else: > return "ok" > ... > > by invoking the test controllers myLogin function i get : > > Traceback (most recent call last): > File "D:\DEV\python\web2py\stable\web2py_src\web2py\gluon > \restricted.py", line 188, in restricted > exec ccode in environment > File "D:/DEV/python/web2py/stable/web2py_src/web2py/applications/ > error/controllers/test.py", line 23, in <module> > File "D:\DEV\python\web2py\stable\web2py_src\web2py\gluon > \globals.py", line 96, in <lambda> > self._caller = lambda f: f() > File "D:/DEV/python/web2py/stable/web2py_src/web2py/applications/ > error/controllers/test.py", line 15, in iphoneLogin > user = auth.login_bare(username, password) > File "D:\DEV\python\web2py\stable\web2py_src\web2py\gluon\tools.py", > line 1306, in login_bare > user = self.db(table_user[userfield] == username).select().first() > UnboundLocalError: local variable 'userfield' referenced before > assignment > > in: > > def login_bare(self, username, password): > ...... > elif 'username' in table_user.fields: > userfield = 'username' > else: > userfield = 'email' > passfield = self.settings.password_field > user = self.db(table_user[userfield] == > username).select().first() <-------- local variable 'userfield' > referenced before assignment > > password = table_user[passfield].validate(password)[0] > if user: > if not user.registration_key and user[passfield] == > password: > user = Storage(table_user._filter_fields(user, > id=True)) > > seems to be there is no userfield 'username' anyhow? > > interestingly it works with 1.84.1 as expected > > for testing here the project if your > interested:http://rapidshare.com/files/420164051/web2py.app.error.w2p