# Configure routes available at '/%namespace%/' context paths sites.ApplicationRequestHandler.bind(namespaced_routes) app_routes = [(r'(.*)', sites.ApplicationRequestHandler)] # enable Appstats handlers if requested appstats_routes = [] if appengine_config.gcb_appstats_enabled(): import google.appengine.ext.appstats.ui as appstats_ui # add all Appstats URL's to /admin/stats basepath for path, handler in appstats_ui.URLMAP: assert '.*' == path[:2] appstats_routes.append(('/admin/stats/%s' % path[3:], handler)) # i18n configuration for jinja2 webapp2_i18n_config = {'translations_path': os.path.join( appengine_config.BUNDLE_ROOT, 'modules/i18n/resources/locale')} # init application app = users.AuthInterceptorWSGIApplication( None, config={'webapp2_extras.i18n': webapp2_i18n_config}, debug=not appengine_config.PRODUCTION_MODE) # setup router app.router = sites.WSGIRouter( lifecycle_routes + global_routes + appstats_routes + app_routes) # hook exception handling app.handle_exception = sites.handle_exception
# Collect routes (URL-matching regexes -> handler classes) for modules. global_routes, namespaced_routes = custom_modules.Registry.get_all_routes() # Configure routes available at '/%namespace%/' context paths sites.ApplicationRequestHandler.bind(namespaced_routes) app_routes = [(r'(.*)', sites.ApplicationRequestHandler)] # enable Appstats handlers if requested appstats_routes = [] if appengine_config.gcb_appstats_enabled(): import google.appengine.ext.appstats.ui as appstats_ui # add all Appstats URL's to /admin/stats basepath for path, handler in appstats_ui.URLMAP: assert '.*' == path[:2] appstats_routes.append(('/admin/stats/%s' % path[3:], handler)) # i18n configuration for jinja2 webapp2_i18n_config = { 'translations_path': os.path.join(appengine_config.BUNDLE_ROOT, 'modules/i18n/resources/locale') } # init application app = users.AuthInterceptorWSGIApplication( None, config={'webapp2_extras.i18n': webapp2_i18n_config}, debug=not appengine_config.PRODUCTION_MODE) app.router = sites.WSGIRouter(global_routes + appstats_routes + app_routes) app.handle_exception = sites.ApplicationRequestHandler.handle_exception