On Fri, Jul 30, 2010 at 03:55:55AM +1100, Daniel Kluev wrote:
> I'm using app_globals out of requests threads context as well, and found
> that easiest way to fix it is to push app_globals into according
> StackRegistry in load_environment:
> config/environment.py:
>         # Setup cache object as early as possible
>         import pylons
>         pylons.cache._push_object(config['pylons.app_globals'].cache)
> 
>         # Create the Mako TemplateLookup, with the default auto-escaping
>         config['pylons.app_globals'].mako_lookup = TemplateLookup(
>             directories=paths['templates'],
>             error_handler=handle_mako_error,
>             module_directory=os.path.join(app_conf['cache_dir'],
> 'templates'),
>             input_encoding='utf-8', default_filters=['escape'],
>             imports=['from webhelpers.html import escape'])
> 
> +        # Make app_globals be avaiable out of request context
> +        pylons.app_globals._push_object(config['pylons.app_globals'])

I'd rather do that in my TestCase.setUp() (and call _pop_object() in the
corresponding tearDown()).

Marius Gedminas
-- 
A programmer started to cuss
Because getting to sleep was a fuss
As he lay there in bed
Looping 'round in his head
was: while(!asleep()) sheep++;

Attachment: signature.asc
Description: Digital signature

Reply via email to