I have created a ticket with a patch:


On 11-Oct-06, at 11:53 AM, Matthew Bevan wrote:

In fact, very bad things(TM) happen.  A user of TurboMail brought the issue to my attention, and now that I need to use sessions in my current project, I have also run into it.  The problem is pretty simple: with sessions enabled, KID attempts to get the current locale from the session, even when the current request (and thus session) are not available.

Adding the following two lines to the top of _get_locale in turbogears/i18n/utils.py fixes the problem:

if not request_available():
return config.get("i18n.default_locale", "en")

My log and traceback:

2006-10-11 11:22:45,212 turbomail.pool DEBUG Estimate 1 work units in the queue.
2006-10-11 11:22:45,213 turbomail.pool DEBUG Creating 1 threads.
2006-10-11 11:22:45,214 turbomail.pool DEBUG Thread pool worker starting up.
2006-10-11 11:22:45,214 turbomail.dispatch DEBUG Creating SMTP object.
2006-10-11 11:22:47,322 turbomail.pool DEBUG Worker starting work.
2006-10-11 11:22:47,323 turbomail.dispatch INFO Connecting to SMTP server mail.topfloor.ca.
2006-10-11 11:22:49,999 turbomail.dispatch DEBUG TLS enabled on SMTP server.
2006-10-11 11:22:50,000 turbomail.dispatch DEBUG Authenticating as topfloor.
2006-10-11 11:22:50,120 turbokid.kidsupport DEBUG Compiling template for healinghands.templates.mail.welcome
Exception in thread Thread-15:
Traceback (most recent call last):
  File ".../python2.4/threading.py", line 442, in __bootstrap
    self.run()
  File ".../python2.4/threading.py", line 422, in run
    self.__target(*self.__args, **self.__kwargs)
  File ".../turbomail/pool.py", line 113, in wrapper
  File ".../turbomail/pool.py", line 166, in worker
  File ".../turbomail/dispatch.py", line 129, in __call__
  File "b.../turbomail/message.py", line 169, in __call__
  File ".../turbomail/message.py", line 223, in _process
  File ".../TurboKid-0.9.8-py2.4.egg/turbokid/kidsupport.py", line 165, in transform
    data.update(self.get_extra_vars())
  File ".../TurboGears-1.0b1-py2.4.egg/turbogears/view/base.py", line 319, in stdvars
    locale = get_locale(),
  File ".../TurboGears-1.0b1-py2.4.egg/turbogears/i18n/utils.py", line 51, in get_locale
    locale = get_locale_f()
  File ".../TurboGears-1.0b1-py2.4.egg/turbogears/i18n/utils.py", line 62, in _get_locale
    locale = cherrypy.session.get(locale_key)
  File ".../CherryPy-2.2.1-py2.4.egg/cherrypy/filters/sessionfilter.py", line 431, in __getattr__
    sess = cherrypy.request._session
  File ".../CherryPy-2.2.1-py2.4.egg/cherrypy/__init__.py", line 42, in __getattr__
    childobject = getattr(serving, self.__attrname__)
AttributeError: 'thread._local' object has no attribute 'request'

Making the modification to my local copy of TG-1.0b1 makes TurboMail happy when using KID templates outside of a request with sessions enabled.

Matthew Bevan, Systems Administrator
Top Floor Computer Systems Ltd.




--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to