On 13. des. 2006, at 19.04, Diez B. Roggisch wrote:

>
> Rune Hansen schrieb:
>> Hi all,
>> I've got a server that needs to call a method in a running TG server
>> without resorting to a HTTP request.
>>
>> So far all I've been able to produce is a traceback:
>> Traceback (most recent call last):
>>    File "/Library/Frameworks/Python.framework/Versions/2.4//lib/
>> python2.4/threading.py", line 442, in __bootstrap
>>      self.run()
>>    File "/Users/roderik/Documents/workspace/mailscheduler/
>> mailscheduler/controllers/scheduler.py", line 64, in run
>>      r.send_mail(customer_object)
>>    File "/Users/roderik/Documents/workspace/mailscheduler/
>> mailscheduler/controllers/root.py", line 85, in send_mail
>>      return mh.send_mail()
>>    File "<string>", line 3, in send_mail
>>    File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
>> python2.4/site-packages/TurboGears-1.0b2-py2.4.egg/turbogears/
>> controllers.py", line 326, in expose
>>      accept = cherrypy.request.headers.get('Accept', "").lower()
>>    File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
>> python2.4/site-packages/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'
>>
>> In short;
>> - I start a  thread in in start_myproj.py.
>> - This thread are listening on a queue and when a queue object is
>> available it tries to call a method in the root controller
>> - The root controller method, in turn, sets up the mailer  
>> (TurboMail).
>> - The result is AttributeError: 'thread._local' object has no
>> attribute 'request'
>>
>> Is there any way round this except for having the server call it self
>> via HTTP?
>
> The exposed methods rely on being called from a http context. Isn't it
> possible for you to factorize out the code that you want to call,  
> put it
> in a undecorated method, and call that from your thread as well as  
> from
> the exposed method?
>
> Diez

No, Im afraid not. Not in this case.
The point was that I wanted to use the same method for "view" and  
"html-mail" so I need the method to return the rendered KID template.
If I try to render the template directly in my thread using KID, KID  
insists on using us-ascii to interpret the template. Perhaps I should  
switch to genshi.

regards
/rune


>
> >


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