On Tuesday, March 15, 2016 at 6:09:05 PM UTC-4, Alex wrote: > > Do you know why there is a difference if the dict is accessed inside or >> outside a controller function? >> > > I still don't understand why it behaves correctly when accessed inside a > controller function. I tried setting a new value in a controller function > (e.g. auth.user.test = '1') and the session is written as expected > (session._unchanged returns false). If I access a dict in a controller > function (e.g. auth.user_groups) the session is not updated > (session._unchanged returns false). How is this possible? >
I'm not sure exactly what's going on, but I assume it has something to do with the call stack and creating objects in the global scope. Note, the effect occurs only when dictionary iteration/item access results in object creation in the global scope. So, this will trigger the effect: myvalues = mydict.values() but this will not: mydict.myvalues() # No assignment here. Anthony -- 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.