Hi,
I need the same thing for tmpl_context.

I've built the skeleton of the decorator but I need more information
to fill in the gaps.

@contextmanager
def set_tmpl_context_cm():
    tc = ????
    pylons.tmpl_context._push_object(tc)
    try:
        yield
    finally:
        pylons.tmpl_context._pop_object()

Where can I get the "tc" (tmpl_context)? Which parameters do I need?

Thanks

León

On Jul 18, 2:11 pm, León Domingo <[email protected]> wrote:
> Thanks a lot, Diez
>
> León Domingo
>
> *ender*
> *LA FACTORÍA DE SOFTWARE*
>
> Av. Cerro del Águila 7, 2ª planta - S23
> 28703 S.S. de los Reyes
> Madrid
>
> tlf. y fax: 902 01 44 01
> *www.ender.es*
>
> On 18 July 2011 14:03, Diez B. Roggisch <[email protected]> wrote:
>
>
>
>
>
>
>
> > On Monday, July 18, 2011 01:26:15 pm León Domingo wrote:
> > > Hi,
> > > I'm writing an script inside my TG2 app which I want to run in the
> > > terminal and I'm not able to access the ugettext or lazy_ugettext
> > > functions.
>
> > > from pylons.i18n import ugettext as _, lazy_ugettext as l_
>
> > > I'm getting this error
>
> > > TypeError: No object (name: translator) has been registered for this
> > > thread
>
> > You need to register the translator for the given thread. This is from some
> > of
> > our code that works:
>
> > import pylons
> > from pylons.i18n.translation import _get_translator
>
> > # this is a hook that is needed to set up some
> > # things that are needed inside transaction hooks
> > @contextmanager
> > def set_language_context_manager(language=None, **kwargs):
> >    # this is stolen from the pylons test setup.
> >    # it will make sure the gettext-stuff is working
> >    translator = _get_translator(language, **kwargs)
> >    pylons.translator._push_object(translator)
> >    try:
> >        yield
> >    finally:
> >        pylons.translator._pop_object()
>
> > HTH,
>
> > Diez
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "TurboGears" 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/turbogears?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en.

Reply via email to