Hi,
I don't understand why request.exception is None when i raise an
exception :
I would like to test using add_request_method to manage a postgresql
connection with commit/rollback in finished_callback but i think i miss
something...
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
def end(request):
print "END"
print "request.exception=%s" % request.exception
def start(request):
print "START"
request.add_finished_callback(end)
return "x"
def index(request):
request.x
0/0
return Response("Hello")
if __name__ == '__main__':
config = Configurator()
config.add_request_method(start, "x", property=True, reify=True)
config.add_route('index', '/')
config.add_view(index, route_name='index')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()
START
END
request.exception=None
Traceback (most recent call last):
File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File
"/home/wilk/.virtualenvs/pyram/local/lib/python2.7/site-packages/pyramid/router.py",
line 272, in __call__
response = self.invoke_subrequest(request, use_tweens=True)
File
"/home/wilk/.virtualenvs/pyram/local/lib/python2.7/site-packages/pyramid/router.py",
line 247, in invoke_subrequest
response = handle_request(request)
File
"/home/wilk/.virtualenvs/pyram/local/lib/python2.7/site-packages/pyramid/tweens.py",
line 21, in excview_tween
response = handler(request)
File
"/home/wilk/.virtualenvs/pyram/local/lib/python2.7/site-packages/pyramid/router.py",
line 163, in handle_request
response = view_callable(context, request)
File
"/home/wilk/.virtualenvs/pyram/local/lib/python2.7/site-packages/pyramid/config/views.py",
line 385, in viewresult_to_response
result = view(context, request)
File
"/home/wilk/.virtualenvs/pyram/local/lib/python2.7/site-packages/pyramid/config/views.py",
line 501, in _requestonly_view
response = view(request)
File "small.py", line 19, in index
0/0
ZeroDivisionError: integer division or modulo by zero
127.0.0.1 - - [16/Jan/2014 13:10:12] "GET / HTTP/1.1" 500 59
Thanks
--
William
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.