First: tmpl_context. This is a variable that's filled in on a per-request basis. It simply does not make sense for a command line application. I'm not fond of saying that, but it really doesn't. So much so that attempting to use it for a command line application makes me think something is possibly wrong/broken with your design for the command line.
What are you actually trying to accomplish, and why does it seem to require tmpl_context? If you can answer those questions, we can devise better answers for how to get you what you need, without trying to use something that should only be used in the web. For the logging, that's not so much fun. Logging is handled by the Python logging module. Check out http://docs.python.org/library/logging.html for an overview of the whole process. This will help to explain what handlers are, why you need them, and how they fit into the whole process. Next, check out http://docs.python.org/library/logging.handlers.html#module-logging.handlersfor documentation on what handlers come with Python. You can write your own, but these are a good start. Finally, check out http://docs.python.org/library/logging.config.html#module-logging.config for a detailed explanation of ways to do configuration, including how to add handlers to your .ini file to make things work the way you expect. You see, the problem with the "no handlers could be found" bit is that you need to add a handler for logging, or it won't work. All of those links I gave will go over the process in great detail, and are very helpful. I recommend using them, rather than asking me to retype everything from them here :) On Thu, Aug 11, 2011 at 5:05 AM, León Domingo <[email protected]> wrote: > Hi, > In fact I need to know how setup TG so I can execute scripts (shell) > using all the stuff I've already available in my app > > The problem now is tmpl_context, as I said before, and logging. The > message is: > > No handlers could be found for logger "foo" > > in a line like this > > logger = logging.getLogger('foo') > > Thanks > > León > > On Aug 11, 9:06 am, León Domingo <[email protected]> wrote: > > 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. > > -- Michael J. Pedersen My IM IDs: Jabber/[email protected], AIM/pedermj022171 Yahoo/pedermj2002, MSN/[email protected] My LinkedIn Profile: http://www.linkedin.com/in/michaeljpedersen Twitter: pedersentg -- 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.

