[google-appengine] Organizing webapp2 application
Im trying to find the right way to organize my webapp2 application. This is the file structure: /my-app app.yaml main.app /views index.html /handlers __init__.py base.py home.py handlers/base.py import webapp2from webapp2_extras import jinja2 class BaseHandler(webapp2.RequestHandler): @webapp2.cached_property def jinja2(self): return jinja2.get_jinja2(app=self.app) def render_response(self, _template, **context): rendered_template = self.jinja2.render_template(_template + '.html', **context) return self.response.write(rendered_template) All the handlers extends the BaseHandler handlers/home.py from base import BaseHandler# Not sure about importing BaseHandler here class Name(BaseHandler): def post(self, name=None): context = { 'name': name, } self.render_response('index', **context) and this is the main.py file import osimport webapp2from webapp2_extras import jinja2 CONFIG = { 'debug': True, 'webapp2_extras.jinja2': { 'autoescape': True, 'template_path': os.path.join(os.path.dirname(__file__), 'views'), 'globals': { 'url_for': webapp2.uri_for, }, },} app = webapp2.WSGIApplication([ webapp2.Route('/name', handler='handlers.home.Name http://handlers.home.name/', name='name'),], config = CONFIG, debug = CONFIG['debug']) Should I put the routes in the same file? Because all the handlers extends the BaseHandler i´m not sure if that is the right way to do that. Also I´m importing webapp2 and extras twice. thx for the advice -- You received this message because you are subscribed to the Google Groups Google App Engine group. To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscr...@googlegroups.com. To post to this group, send email to google-appengine@googlegroups.com. Visit this group at http://groups.google.com/group/google-appengine. For more options, visit https://groups.google.com/groups/opt_out.
[google-appengine] Organizing webapp2 application
Im trying to find the right way to organize my webapp2 application. This is the file structure: /my-app app.yaml main.app /views index.html /handlers __init__.py base.py home.py handlers/base.py import webapp2from webapp2_extras import jinja2 class BaseHandler(webapp2.RequestHandler): @webapp2.cached_property def jinja2(self): return jinja2.get_jinja2(app=self.app) def render_response(self, _template, **context): rendered_template = self.jinja2.render_template(_template + '.html', **context) return self.response.write(rendered_template) All the handlers extends the BaseHandler handlers/home.py from base import BaseHandler# Not sure about importing BaseHandler here class Name(BaseHandler): def post(self, name=None): context = { 'name': name, } self.render_response('index', **context) and this is the main.py file import osimport webapp2from webapp2_extras import jinja2 CONFIG = { 'debug': True, 'webapp2_extras.jinja2': { 'autoescape': True, 'template_path': os.path.join(os.path.dirname(__file__), 'views'), 'globals': { 'url_for': webapp2.uri_for, }, },} app = webapp2.WSGIApplication([ webapp2.Route('/name', handler='handlers.home.Name', name='name'),], config = CONFIG, debug = CONFIG['debug']) Should I put the routes in the same file? Because all the handlers extends the BaseHandler i´m not sure if that is the right way to do that. Also I´m importing webapp2 and extras twice. thx for the advice diego -- You received this message because you are subscribed to the Google Groups Google App Engine group. To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscr...@googlegroups.com. To post to this group, send email to google-appengine@googlegroups.com. Visit this group at http://groups.google.com/group/google-appengine. For more options, visit https://groups.google.com/groups/opt_out.