On Wed, Jun 8, 2011 at 11:50 AM, Mike Orr <[email protected]> wrote:
> On Wed, Jun 8, 2011 at 7:11 AM, mehdi0016 <[email protected]> wrote: > > Hi > > How could i add some global attribute to my pyramid application to use > > them cross-application or cross-request? > > thanks. > > For cross-request variables, put them in the 'settings' dict, > available as 'settings' in main() and as 'request.registry.settings' > in views. > > By cross-application variables, do you mean across the entire > application? If so, the same thing applies. I'm not sure how to access > the registry outside a request. If you can't find it in the docs you > can try ``pyramid.threadlocal.get_current_request()`` as a last > resort. > > -- > We made an app config object and registered it in the registry at configuration time. Our config object first checks for keys in a config key/value table, then on attributes of itself ( for class level attributes ) and then in the values in the ini file. When we need to get it, we can use standard ZCA code to get the config obj, though I made a request factory that attaches it as an attribute of request too. It's working well for us, but YMMV. iain -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
