Dear list,

we are trying to use the "render()" function from within websetup.py. 
Actually it's not exactly websetup.py but a batch script that is derived 
from websetup.py. We want to send emails from that script and thought that 
it might be nice to use Mako templates for that purpose. Unfortunately 
things aren't as simple as we thought.

Our script:

============================================================
# -*- coding: utf-8 -*-
# render test in pylons context

filename='/path/to/development.ini'

from paste.deploy import appconfig
from pylons import config
from pylons.templating import render
from debexpo.config.environment import load_environment

conf = appconfig('config:' + filename)
load_environment(conf.global_conf, conf.local_conf)

print render('/email/changes_list.mako')
============================================================

Unfortunately this fails with:

============================================================
python bin/render.py
Traceback (most recent call last):
  File "bin/render.py", line 14, in <module>
    print render('/email/changes_list.mako')
  File "/var/lib/python-support/python2.5/pylons/templating.py", line 343, 
in render
    return pylons.buffet.render(template_name=template, fragment=fragment,
  File "/var/lib/python-support/python2.5/paste/registry.py", line 137, in 
__getattr__
    return getattr(self._current_obj(), attr)
  File "/var/lib/python-support/python2.5/paste/registry.py", line 194, in 
_current_obj
    'thread' % self.____name__)
TypeError: No object (name: Buffet) has been registered for this thread
============================================================

Does anyone have an idea what we need to initialise further to get the 
ability to call render here?

Cheers
 Christoph
-- 
When you do things right people won't be sure you've done anything at all.

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to