Looking at the rewrite code, it appears that when an error occurs and there is no router being used (as in your development environment), the request.env.request_uri value does not get changed from its original value -- so when the routes_onerror action is called, it sees the original request_uri rather than the URI of the error action itself.
On the other hand, if you are using a router (as in your production environment), when an error occurs, the request.env.request_uri value ends up getting changed to the URI of the error action itself, which is why you see a different URI on your production server. Maybe submit a ticket about this -- the behavior should probably be the same regardless of whether you happen to be using a router (I'm not sure which behavior is preferable, but probably the first one, as the error action is not technically a separate HTTP request but simply an internal re-routing of the initial HTTP request to a different handler -- so the original request_uri should probably be retained). In any case, the original URI is passed to the error action in the query string as the "requested_uri" variable, and as indicated in the documentation, that is the proper way to get the URI of the original request (this method generalizes to the case where the error handler is external to the web2py process of the app that generated the error). Anthony On Thursday, December 4, 2014 1:44:46 PM UTC-5, Jim S wrote: > > I am using the technique shown here ( > http://web2py.com/books/default/chapter/29/04/the-core?#Routes-on-error) > to send email notifications when a ticket is generated for my app. > > I'm getting different behaviors on my development and test environments. > > Test environment: > web2py version 2.10.0-beta+timestamp.2014.09.24.13.35.58 > Running the rocket web server on windows > routes.py: > routes_onerror = [ > > ('connect/*', '/connect/default/error_handler') > ] > > > > > Production environment: > web2py version 2.9.5-turn+timestamp.2014.08.06.14.51.23 > Running nginx/uwsgi on Ubuntu > routes.py: > default_application = 'connect' # ordinarily set in base routes.py > default_controller = 'dashboard' # ordinarily set in app-specific > routes.py > default_function = 'index' # ordinarily set in app-specific routes.py > > > routers = dict(BASE=dict(domains={'www.infocenter.qlf.com':'connect'... > there is more here, but this line is not the problem} > > routes_onerror = [ > ('connect/*', '/connect/default/error_handler') > ] > > > I'm using this to get the URI in my error handler: > requested_uri = request.env.request_uri > > > On my development system it returns: > > */connect/asset/index?asset_type=0&search_text=table* > > On my production system, it returns: > > > */connect/default/error_handler?code=500&ticket=connect/99.99.99.99.2014-12-04.12-10-04.41078001-775c-4d48-a841-dcb5391d3721&requested_uri=%2Fconnect%2Fasset%2Findex%3Fasset_type%3D0%26search_text%3Dtest&request_url=/asset* > > (the 99.99.99.99 above was the IP address) > > Any idea why it returns the different URI on the production system? > > > NOTE - I have 2 production servers, the second is running > Windows/Apache/mod-wsgi and is exhibiting the same behavior as the ubuntu > (other production) server. > > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

