Closed GoogleCodeExporter closed 8 years ago
This is not documented, but webapp2 doesn't include a config object by default.
You must do:
import webapp2
from webapp2_extras import config as extras_config
app_config = {}
app_config['webapp2_extras.sessions'] = {
'secret_key': 'some-secret-key',
}
app = webapp2.WSGIAppplication([...routes...])
app.config = extras_config.Config(app_config)
I'm sorry for the trouble, and I'll add a page to the docs explaining how to
make the config used by some of the extras modules available.
Original comment by rodrigo.moraes
on 3 Jun 2011 at 6:12
This issue was closed by revision 76b7b45014a2.
Original comment by rodrigo.moraes
on 3 Jun 2011 at 6:35
As a side note, you must leave the application object outside of main():
application = webapp2.WSGIApplication([('/', 'main.MainHandler')],
debug=True)
def main():
util.run_wsgi_app(application)
This way the app is created once and not on every request.
Original comment by rodrigo.moraes
on 3 Jun 2011 at 6:38
After this issue, I decided to add a simple configuration object to the WSGI
app, which now can be initialized with a config dictionary:
app = webapp2.WSGIApplication(routes, debug=True, config={})
A full explanation and example are here:
http://webapp-improved.appspot.com/guide/extras.html
The error "'WSGIApplication' object has no attribute 'config'" will no longer
occur, as a separate config doesn't need to be set. The sessions module,
however, requires a secret_key to be set.
Thanks for the feedback. :)
Original comment by rodrigo.moraes
on 4 Jun 2011 at 11:28
Original issue reported on code.google.com by
fd97...@gmail.com
on 3 Jun 2011 at 5:31