The fix in trunk worked for me. Martin are you calling impersonate(0) via GET or POST.
Now I'm going to guessing mode.... I guest it is via GET, right? And probably when you call it you were not an impersonator any more. Massimo, maybe it is a condition missing: we have in gluon/tools.py: elif user_id in (0, '0') and self.is_impersonating(): session.clear() session.update(cPickle.loads(auth.impersonator)) self.user = session.auth.user return None Probably should go something like this: elif user_id in (0, '0'): if self.is_impersonating(): session.clear() session.update(cPickle.loads(auth.impersonator)) self.user = session.auth.user return None Ricardo On Tue, Oct 16, 2012 at 2:31 PM, Martin Weissenboeck <mweis...@gmail.com> wrote: > > > Traceback (most recent call last): > > > File "H:\...\web2py\gluon\restricted.py", line 209, in restricted > > > exec ccode in environment > File "H:/.../web2py/applications/secure/controllers/default.py", line > 3988, in <module> > > > File "H:\...\web2py\gluon\globals.py", line 182, in <lambda> > > > > self._caller = lambda f: f > () > > > File "H:/.../web2py/applications/secure/controllers/default.py", line > 1932, in impersonateEnd > > > auth.impersonate(0) > File "H:\...\web2py\gluon\tools.py", line 2756, in impersonate > > > > return SQLFORM(table_user, user.id, readonly=True) > > > UnboundLocalError: local variable 'user' referenced before assignment > > > > 2012/10/16 Massimo Di Pierro <massimo.dipie...@gmail.com> >> >> can you show all traceback? >> >> >> On Tuesday, 16 October 2012 07:18:38 UTC-5, mweissen wrote: >>> >>> Is this the actual trunc-version? >>> >>> Version 2.1.1 (2012-10-16 06:19:35) dev >>> >>> >>> I get the same message >>> >>> <type 'exceptions.UnboundLocalError'> local variable 'user' referenced >>> before assignment >>> >>> >>> 2012/10/16 Massimo Di Pierro <massimo....@gmail.com> >>> >>>> There is a bug, I just fixed it in trunk. >>>> >>>> auth.impersonate(0) >>>> is correct. >>>> >>>> >>>> On Tuesday, 16 October 2012 04:38:35 UTC-5, mweissen wrote: >>>>> >>>>> I have called >>>>> auth.impersonate(0) >>>>> to finish impersonation. >>>>> >>>>> Now (Version 2.1.1) I see: >>>>> >>>>> Traceback (most recent call last): >>>>> File "H:\...\web2py\gluon\restricted.py", line 209, in restricted >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> exec ccode in environment >>>>> File "H:/.../applications/secure/controllers/default.py", line 3988, >>>>> in <module> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> File "H:\...\web2py\gluon\globals.py", line 187, in <lambda> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> self._caller = lambda f: f() >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> File "H:/.../applications/secure/controllers/default.py", line 1932, >>>>> in impersonateEnd >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> auth.impersonate(0) >>>>> File "H:\...\web2py\gluon\tools.py", line 2755, in impersonate >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> return SQLFORM(table_user, user.id, readonly=True) >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> UnboundLocalError: local variable 'user' referenced before assignment >>>>> >>>>> >>>>> My function: >>>>> def impersonateEnd(): >>>>> auth.impersonate(0) >>>>> redirect(URL('index',vars=dict(flash=T('End of impersonation')))) >>>>> >>>>> What ist the best way to end impersonation? >>>>> >>>>> Regards, Martin >>>> >>>> > -- > > > --