Well, sorry to bother, I think I got it. I've just had to set the full path to the error handler, like 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, 'http://mainapp.com/admin/error_handler')) routes_onerror.append((r'%s/*' % app, 'http://mainapp.com/admin/error_handler')) Because mainapp.com is configured to serve the application mainapp, it's not necessary to include it in the url. However, it's good to consider that, on error, the user will be redirected to other domain, I don't like the idea too much. But that's another story. El jueves, 3 de marzo de 2016, 11:25:12 (UTC-3), Lisandro escribió: > > 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. > > > > > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.