On Thu, Apr 23, 2009 at 09:45, Ben Bangert <[email protected]> wrote:

>
> What are you using to raise the exception, and where are you raising it in
> your project? The Pylons WSGIController captures http exceptions, and turns
> them into normal responses, which the StatusCodeRedirect will then capture
> and release. However, it is capturing webob's HTTPException classes, and you
> might be using Paste's HTTPException classes.
>
> Try using the abort that you import from pylons and it should work, or
> switch to using the webob.exc module which has the same Paste
> httpexceptions, except the Pylons WSGIController catches them.
>

I am using abort and redirect_to imported from pylons, I do not use
HTTPExceptions directly (neither webob nor paste).

I've added a print to WSGIController it shows exception of type
webob.exc.HTTPNotFound.
(line 109)
        try:
            result = self._perform_call(func, args)
        except HTTPException, httpe:
...
            result._exception = True

So it seems that the exception gets intercepted correctly. There is probably
something wrong down the pipeline. StatusCodeRedirects?


Again, here is full sequence.

My code calls abort(404). Browser shows:

 File "/home/max/projects/site-baseline/doupy/doupy/lib/base.py", line
215, in __call__
    redirect_permanently(url)
  File "/home/max/projects/site-baseline/doupy/doupy/lib/base.py",
line 47, in redirect_permanently
    redirect(url, code=301) # Moved permanently
  File 
"/home/max/projects/site-baseline/py/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/util.py",
line 210, in redirect
    raise exc(location=url).exception
HTTPMovedPermanently: 301 Moved Permanently
Content-Type: text/html; charset=UTF-8
Content-Length: 0
location: http://127.0.0.1:5010/error/document/


It seems to go as following: the HTTPNotFound gets intercepted,
StatusCodeRedirects creates "internal redirect" to /error/document/ but
forwarding to this url fails for some reason. I have turned on DEBUG
logging, here is what happens:

09:30:10,110 DEBUG pylons.controllers.core Looking for u'archive' method to
handle the request
09:30:10,111 DEBUG pylons.controllers.core Calling 'archive' method with
keyword args: **{}
09:30:10,111 DEBUG pylons.controllers.util Aborting request, status: 404,
detail: '', headers: None, comment: None
09:30:10,111 DEBUG pylons.controllers.core 'archive' method raised
HTTPException: HTTPNotFound (code: 404)
Traceback (most recent call last):
  File
"/home/max/projects/site-baseline/py/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 107, in _inspect_call
    result = self._perform_call(func, args)
  File
"/home/max/projects/site-baseline/py/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 60, in _perform_call
    return func(**args)
  File
"/home/max/projects/site-baseline/doupy/doupy/controllers/jobboard.py", line
302, in archive
    abort(404)
  File
"/home/max/projects/site-baseline/py/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/util.py",
line 196, in abort
    raise exc.exception
HTTPNotFound: 404 Not Found
Content-Type: text/html; charset=UTF-8
Content-Length: 0


09:30:10,111 DEBUG pylons.controllers.core Controller returned a Response
object, merging it with pylons.response
09:30:10,112 DEBUG pylons.controllers.core Calling Response object to return
WSGI data
09:30:10,177 DEBUG routes.middleware Matched GET /error/document
09:30:10,177 DEBUG routes.middleware Route path: 'error/:action/:id',
defaults: {'action': 'index', 'controller': u'error', 'id': None}
09:30:10,178 DEBUG routes.middleware Match dict: {'action': u'document',
'controller': u'error', 'id': None}
09:30:10,178 DEBUG pylons.wsgiapp Setting up Pylons stacked object globals
09:30:10,178 DEBUG pylons.wsgiapp Resolved URL to controller: u'error'
09:30:10,179 DEBUG pylons.wsgiapp Found controller, module:
'doupy.controllers.error', class: 'ErrorController'
09:30:10,179 DEBUG pylons.wsgiapp Controller appears to be a class,
instantiating
09:30:10,179 DEBUG pylons.wsgiapp Calling controller class with WSGI
interface
09:30:10,179 DEBUG pylons.controllers.util Generating 301 redirect

If I simply open http://127.0.0.1:5010/error/document/ it opens as expected.
So routing to this url works.

What's wrong???

Max.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to