I have never used it myself but I would imagine that you could handle the exception event with a filter to prevent circuits from throwing it's traceback.
If it defines a __call_(environ, start_response) ...
Then it _is_ a WSGI Application / Callable.
IN that case do this:
Gateway("/weberror", EvalException())
That will create the EvalException application
instance and mount it on the web path /weberror
(using the circuits.web server / framework).
It should then be accessible via:
http://localhost:8000/weberror (for example)
Hope this helps,
cheers
James
--
-- James Mills
--
-- "Problems are solved by method"
You can try to listen to the web:httperror events and
re-raise the exception. That might work. I haven't tested this
(I'm asking you to) :)
Let me know... Otherwise I'll find the "right way" to do that...
> I did come across the following exception while messing with it:
>
> File '/home/bickersfam/circuits/lib/python2.6/site-packages/
> WebError-0.10.3-py2.6.egg/weberror/evalexception.py', line 424 in
> detect_start_response
> return start_response(status, headers, exc_info)
> File '/home/bickersfam/circuits/lib/python2.6/site-packages/
> circuits-1.5-py2.6.egg/circuits/web/wsgi.py', line 170 in
> start_response
> self._response.headers.add_header(*header)
> File '/home/bickersfam/circuits/lib/python2.6/site-packages/
> circuits-1.5-py2.6.egg/circuits/web/headers.py', line 272 in
> add_header
> self._headers.append((_name, "; ".join(parts)))
> TypeError: sequence item 0: expected string, long found
>
> That exception passed back to EvalException and I got a nice
> interactive debugger in my browser and was able to see that
> evalexception passed a header 'Content-Length'=71667L which isn't the
> string circuits.web was expecting. This might be a problem in my own
> controller; I'll have to look into that later, but the important thing
> is that EvalException worked nicely for that exception.
This might be a new bug you've discovered.
If you could do some "debugging" and let me know if
there's something I need to fix with circuits.web ?
Thanks,
Hmmm unfortunately due to the architecture of circuits
I'm not exactly sure how to accomplish what you want
and what the evalexception middleware needs.
The basic problem is this...
If you have a look at circuits/core/manager.py
at about L445 -- the __handleEvent method
You'll see that any and every exception that may
occur in a circuits application is trapped, cleaned up
and an appropriate Event fired for it (which the HTTP
protocol Component in circuits.web listens for).
I'm not sure how to pass the exception back up the chain
unless I were to add a setting into the Manager (the base
of all components) that told it to re-raise exceptions so that
things like evalexcception could then trap them.
I wonder though if it might be possible to somehow listen
to the web:httperror event and instead weave in the
evalexception middleware right then. Meaning that you
do a return evalexception() -- where evalexception() returns
a valid response (somehow) -- You might have to do some
integration of some circuits.web.wsgi.Gateway with this new
event handler (in your app).
> As best I can figure out, the evalexception middleware passed a header
> ('Content-Length', 29297L) to wsgi.Gateway.start_response(), but
> circuits is expecting all header values to be string or None types.
> Beyond that, I got lost in what's going on.
Cool. Thank you. I'll write a test for this and fix taht bug.
--
You received this message because you are subscribed to the Google Groups "circuits" group.
To post to this group, send email to circuit...@googlegroups.com.
To unsubscribe from this group, send email to circuits-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/circuits-users?hl=en.
I'm not entirely sure what to do here...
This (to me) is a special case - where you want to
pass exceptions out to a wsgi callable (middleware).
Any other ideas ?
Have you seen circuits.web.apps ?
It contains a webconsole (very similar kind of thing).
I'll have a think about this in general some more...