I use app_globlas to create and store the RUM based wsgi application.
class Globals(object):
"""Globals acts as a container for objects available throughout
the
life of the application
"""
def __init__(self):
"""One instance of Globals is created during application
initialization and is available during requests via the
'app_globals' variable
"""
self.task_admin_app = self._make_task_admin_app()
self.site_admin_app = self._make_site_admin_app()
def _make_site_admin_app(self):
# Path to where you are keeping rum-specific templates.
# You can imit this if you're not overriding them.
app = RumApp({
'debug': asbool(config.get('debug')),
'full_stack': True,
'rum.repositoryfactory': {
'use': 'sqlalchemy',
'session_factory': sf.model.meta.Session,
'models': [
sf.model.Page, sf.model.PageItem,
sf.model.AdminPanel, sf.model.AdminTask
]
},
'rum.viewfactory': {
'use': 'toscawidgets',
},
'rum.translator': {
'use': 'default',
'locales': ['es', 'en'],
}
})
return app
>From controllers, I use g.site_admin_app. Somehow I don't like that
but this is recommended approach from RUM developers.
-- Krish
On Dec 21, 3:51 am, Damian <[email protected]> wrote:
> you define them in the Global object.
>
> class Globals(object):
> myconstant = 'astring'
>
> etc...
>
> and then in the app use g.myconstant wherever you need it. These
> don't, by convention, ever get modified. Generally it would be a bad
> idea to do that as it would result in concurrency issues.
>
> It seems like a good place to keep constants that are used throught
> the app.
>
> Damian
>
> On Dec 20, 9:05 pm, Mike Orr <[email protected]> wrote:
>
> > How do you add variables to the globals? I think you'd have to
> > override render_mako.
>
> > On Sun, Dec 20, 2009 at 12:59 PM, Damian <[email protected]> wrote:
> > > FWIW - we make quite heavy use of 'g' for defining constant strings
> > > that are used to generate our JSON, so the javascript knows what to
> > > look for in the template and pylons sends the right stuff back even if
> > > we chose to change the constant string.
>
> > > d
>
> > > On Dec 20, 8:12 pm, Mike Orr <[email protected]> wrote:
> > >> On Sun, Dec 20, 2009 at 10:11 AM, Ben Bangert <[email protected]> wrote:
> > >> > On Dec 18, 2009, at 7:59 PM, Mike Orr wrote:
>
> > >> > Mike, 'c' will remain in templates in 1.0, 'g' will be app_globals,
> > >> > though one can of course add variables as desired to the Pylons
> > >> > globals in templates if 'g' is still desired.
>
> > >> That's fine. 'c' and 'h' are the vital ones. I don't use app_globals
> > >> much anyway, and I've never used it in a template.
>
> > >> --
> > >> Mike Orr <[email protected]>
>
> > > --
>
> > > 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
> > > athttp://groups.google.com/group/pylons-discuss?hl=en.
>
> > --
> > Mike Orr <[email protected]>
--
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.