Hi Anthony, Thanks again for this. I had dozens of vars that were needlessly declared as session vars.
I was wondering how to make global vars declared in a model accessible from a compiled module (that is placed in the modules folder and imported when needed by models and controllers)? e.g. from your example above, how could a compiled module access the DECPLACES global variable? Cheers, j On Fri, Dec 29, 2017 at 4:14 PM, Anthony <[email protected]> wrote: > On Friday, December 29, 2017 at 12:38:24 PM UTC-5, Jordan Ladora wrote: >> >> Brilliant - thank you very much for the thoughtful reply. >> >> I actually set it as a session var bc there are several tables with a >> decimal field that I want to be consistent with each other, >> > > Note, the session is unique per user, so it doesn't make sense to store a > global value in the session, as you are unnecessarily storing a separate > copy of it for each user. Instead, just create a constant somewhere in a > model file and use that in your table definitions: > > DECPLACES = 7 > > Or if the only place you need that constant is in defining decimal fields, > just store the entire field type as a constant: > > DECFIELD = 'decimal(100, 7)' > > Then in your table definitions: > > db.define_table(..., Field('myfield', DECFIELD, ...)) > > 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 a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/web2py/WDUqTculX1Q/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

