I have
several web2py apps, and each one is accessibly from a specific domain. I've achieved this using routes.py.
Also, I'm using routes_onerror inside routes.py in order to show a custom static html file on error. That is working ok.
This is my working routes.py:
# -*- coding: utf-8 -*-
domains = {
'mainapp.com': 'mainapp',
'app1.com': 'app1',
'app2.com': 'app2',
'app3.com': 'app3'}
apps = ['mainapp', 'app1', 'app2', 'app3']
routers = dict(
BASE = dict(
default_controller = 'default',
default_function = 'index',
domains = domains,
root_static = ['robots.txt'],
map_static = True,
exclusive_domain = True,
)
)
routes_onerror = []
for app in apps:
for code in ['403', '404', '500', '503']:
routes_onerror.append((r'%s/%s' %(app, code), r'/%s/static/%s.html' %(app, code)))
routes_onerror.append((r'%s/*' %app, r'/%s/static/500.html' %app))
Up to here, working ok.
Now, I would like to send an email when an internal error server happened, that is, error 500.
So I've modified the routes_onerror part to this:
routes_onerror = []
for app in apps:
for code in ['403', '404', '503']:
routes_onerror.append((r'%s/%s' %(app, code), r'/%s/static/%s.html' %(app, code)))
routes_onerror.append((r'%s/500' %app, '/mainapp/admin/error_handler'))
routes_onerror.append((r'%s/*' %app, '/mainapp/admin/error_handler'))
Basically, it says that 403, 404 and 503 errors will still return a static html file, but error 500 and other types of errors will be processed by /mainapp/admin/error_handler
This works perfectly if the error is thrown from mainapp (that is, the one that also handles the error).
But when an error occurs inside app1, app2 or app3, web2py shows the message "invalid function (default/mainapp)"
It appears to be that web2py is not calling correctly the /main/app/error_handler
Maybe the configuration of routers is some how messed up, and I'm doing it wrong.
Any help or clarification on this will be appreciated.
Regards,
Lisandro.