Alright so I don't know if it's the best solution but it turns out
that if I do this :
# Defining cherrypy.request.tg_template_enginename to avoid error
        cherrypy.request.tg_template_enginename = 'genshi'

        body = controllers._process_output(output, template, format,
content_type, mapping)
        cherrypy.response.headers['Content-Length'] = len(body)
        cherrypy.response.body = body
it works.
Defining the tg_template_enginename variable in cherrypy.request makes
it accept the template and display the page I want.
If this is wrong for some reason please let me know.
Tom

On Aug 18, 10:53 am, Tom Zaffran <[email protected]> wrote:
> I did look into the ErrorReporting page, it's what got me there 
> :http://groups.google.com/group/turbogears/browse_frm/thread/61a48b1f7...
> in the first place.
> I tried adapting the code to what I found in the EggBasket
> ErrorCatcher class but the problem remains. I just basically want a
> user error page for when there is a Page not found error or something
> like that.
> I keep getting this error :
>
> te 'tg_template_enginename'</faultstring></result>HTTP/1.1 404 Not
> Found
> Date: Tue, 18 Aug 2009 08:50:07 GMT
> Server: Apache/2.2.8 (Ubuntu) mod_ssl/2.2.8 OpenSSL/0.9.8g mod_wsgi/
> 1.3 Python/2.5.2
> Set-Cookie: session_id=49f24902337d3eb02d9c509c104f48f8a3fa7ee7;
> expires=Tue, 18 Aug 2009 09:50:07 GMT; Path=/
> Set-Cookie: tg-visit=8ea6fa168f1164a6cb0702a0594b25148d623c0a; Path=/
> Content-Length: 728
> Keep-Alive: timeout=15, max=99
> Connection: Keep-Alive
> Content-Type: text/html; charset=utf-8
>
> <result><debuginfo>
> Traceback:
> Traceback (most recent call last):
>   File "/usr/lib/python2.5/site-packages/CherryPy-2.3.0-py2.5.egg/
> cherrypy/_cphttptools.py", line 134, in _run
>     inst.set_response()
>   File "/usr/lib/python2.5/site-packages/CherryPy-2.3.0-py2.5.egg/
> cherrypy/_cperror.py", line 173, in set_response
>     handler(self.status, self.message)
>   File "/home/tom/cinego/cinego/controllers.py", line 155, in
> _cp_on_http_error
>     body = render_error_template(template, data=output)
>   File "/home/tom/cinego/cinego/controllers.py", line 151, in
> render_error_template
>     content_type, None)
>   File "/usr/lib/python2.5/site-packages/TurboGears-1.1b3-py2.5.egg/
> turbogears/controllers.py", line 96, in _process_output
>     fragment=fragment)
>   File "/usr/lib/python2.5/site-packages/TurboGears-1.1b3-py2.5.egg/
> turbogears/view/base.py", line 194, in render
>     return engine.render(**kw)
>   File "build/bdist.linux-i686/egg/genshi/template/plugin.py", line
> 110, in render
>     return self.transform(info, template).render(**kwargs)
>   File "build/bdist.linux-i686/egg/genshi/core.py", line 179, in
> render
>     return encode(generator, method=method, encoding=encoding,
> out=out)
>   File "build/bdist.linux-i686/egg/genshi/output.py", line 60, in
> encode
>     return _encode(u''.join(list(iterator)))
>   File "build/bdist.linux-i686/egg/genshi/output.py", line 425, in
> __call__
>     for kind, data, pos in stream:
>   File "build/bdist.linux-i686/egg/genshi/output.py", line 753, in
> __call__
>     for kind, data, pos in stream:
>   File "build/bdist.linux-i686/egg/genshi/output.py", line 592, in
> __call__
>     for kind, data, pos in stream:
>   File "build/bdist.linux-i686/egg/genshi/output.py", line 698, in
> __call__
>     for kind, data, pos in chain(stream, [(None, None, None)]):
>   File "build/bdist.linux-i686/egg/genshi/output.py", line 532, in
> __call__
>     for ev in stream:
>   File "build/bdist.linux-i686/egg/genshi/core.py", line 283, in
> _ensure
>     for event in stream:
>   File "build/bdist.linux-i686/egg/genshi/template/base.py", line 569,
> in _include
>     for event in stream:
>   File "build/bdist.linux-i686/egg/genshi/template/markup.py", line
> 298, in _match
>     ctxt, start=idx + 1, **vars):
>   File "build/bdist.linux-i686/egg/genshi/template/markup.py", line
> 245, in _match
>     for event in stream:
>   File "build/bdist.linux-i686/egg/genshi/template/base.py", line 543,
> in _exec
>     for event in stream:
>   File "build/bdist.linux-i686/egg/genshi/template/base.py", line 520,
> in _eval
>     result = _eval_expr(data, ctxt, **vars)
>   File "build/bdist.linux-i686/egg/genshi/template/base.py", line 286,
> in _eval_expr
>     retval = expr.evaluate(ctxt)
>   File "build/bdist.linux-i686/egg/genshi/template/eval.py", line 180,
> in evaluate
>     return eval(self.code, _globals, {'__data__': data})
>   File "/home/tom/cinego/cinego/templates/master.html", line 11, in
> &lt;Expression u'ET(js.display())'&gt;
>     &lt;link py:for="js in tg_js_head" py:replace="ET(js.display())" /
> &gt;
>   File "/usr/lib/python2.5/site-packages/TurboGears-1.1b3-py2.5.egg/
> turbogears/widgets/meta.py", line 91, in lockwidget
>     output = self.__class__.display(self, *args, **kw)
>   File "/usr/lib/python2.5/site-packages/TurboGears-1.1b3-py2.5.egg/
> turbogears/widgets/base.py", line 286, in display
>     if request_available() and request.tg_template_enginename ==
> 'genshi' \
>   File "/usr/lib/python2.5/site-packages/CherryPy-2.3.0-py2.5.egg/
> cherrypy/__init__.py", line 47, in __getattr__
>     return getattr(childobject, name)
> AttributeError: 'Request' object has no attribute
> 'tg_template_enginename'
> </debuginfo><faultcode>Server</faultcode><faultstring>'Request' object
> has no attribute 'tg_template_enginename'</faultstring></result>
>
> I should be able to have a catch all to display a custom page for when
> the user mistyped something. Am I missing something ?
> Tom
>
> On Aug 17, 7:58 pm, Christopher Arndt <[email protected]> wrote:
>
> > zaf schrieb:
>
> > > Hi everyone,
> > > I'm trying to upgrade to TG1.1b3 (b4 is not available in easy_install)
> > > and I have a problem with error reporting.
> > > Based on this page :
> > >http://groups.google.com/group/turbogears/browse_frm/thread/61a48b1f7...
>
> > No solution to your immediate problem, but have you tried the code from
>
> >http://docs.turbogears.org/1.0/ErrorReporting
>
> > Be sure to look at the example project in the page attachments. This
> > might also be a more up-to-date version of the code:
>
> >http://trac.chrisarndt.de/eggbasket/browser/EggBasket/trunk/eggbasket...
>
> > Chris
--~--~---------~--~----~------------~-------~--~----~
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