> > My idea would be to add a warning that the session will be detected as > changed and written to disk etc. (depending on session type) if a dict > value (like auth.user_groups) of the session is accessed outside a > controller function >
Note, the problem occurs when creating new objects in the global scope by iteration/item access of a dictionary. You can avoid the problem by (a) doing the iteration/access inside a function, whether in a model, controller, or view, or (b) avoiding assignment to a variable. Why this is the case is a mystery. In your case, you should be able to do something like the following in a model: def check_roles(): for role in auth.user_groups.itervalues(): ... if auth.user_id: check_roles() Now "role" is no longer in the global scope, and it appears to work. You could also use map(), which won't create any variables in the global scope: outcome = map(some_function, auth.user_group.itervalues()) 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.