Overriding __init__() from webapp2.RequestHandler

235 views
Skip to first unread message

daniloz

unread,
May 1, 2012, 6:23:10 AM5/1/12
to web...@googlegroups.com
Hi All,

I'm trying to override the constructor from webapp2.RequestHandler in order to do an automatic list of pages on my webapp. But it's not working.
Here's what I'm trying to do:

class BaseHandler(webapp2.RequestHandler):
    def __init__(self, request, response, **kwargs):
        self.initialize(request, response)
        logging.info(kwargs)
        self.pageName = kwargs['pageName']

class ChildPage(BaseHandler):
[...]

app = webapp2.WSGIApplication([('/', ChildPage (None,None, dict(pageName='Root Page'))),

But when the page loads, I got the following error:

ERROR    2012-05-01 10:20:31,911 webapp2.py:1553] ' ChildPage ' object is not callable
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1536, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1530, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1065, in __call__
    return self.handler(request, *args, **kwargs)
TypeError: ' ChildPage ' object is not callable

I suspect it's related with the None's I pass to the constructor. 

Any ideas how to skip this or any other way to achieve what I want??

Thanks,
daniloz

ysh

unread,
Oct 8, 2012, 10:22:57 PM10/8/12
to web...@googlegroups.com
I think you should call parent's __init__
Reply all
Reply to author
Forward
0 new messages