GAE for Python 1.7.0
We normally set up the routing like,
PAGE_RE = r'(/(?:[a-zA-Z0-9_-]+/?)*)'
app = webapp2.WSGIApplication([('/?', MainPage),
('/signup', Register),
('/login', Login),
('/logout', Logout),
('/_upload', Upload),
('/_accept', AcceptPost),
('/?' + JSON_LIST_RE, JsonListHandler),
('/(.*).json', JsonHandler),
('/_edit' + PAGE_RE, EditPageHandler),
('/_history' + PAGE_RE, HistoryHandler),
('/?' + PAGE_RE, WordPageHandler),
('/?' + LIST_RE, WordListPageHandler),
('/(.*)', WordPageHandler)
],
debug=True)
An appropriate handler is to be chosen in accordance with the regular expression and the order of the handlers.
But it is getting messy. I need to clean things up.
So hopefully I would like to pass it through conditional statements.
class Conditional(Handler):
def get(self, newpost):
if "+" in newpost:
self.response.write('choice 1')
else:
self.response.write('choice 2')
My question is How can I apply a handler IN the handler?
in the above Conditional(Handler): case, I tried to put 'WordPageHandler'. Certainly it does not seem to work
class Conditional(Handler):
def get(self, newpost):
if "+" in newpost:
WordPageHandler
Is is possible to set up nested handlers?