Shwetanka
Shwetanka

Reputation: 5036

gae-sessions with django on gae

I'm using gae-sessions with django for writing a gae based app. From here

I've added gaesessions.DjangoSessionMiddleware to settings.py. A modification is required in

self.wrapped_wsgi_middleware = SessionMiddleware(fake_app, cookie_key='you MUST change this')

I have put the cookie_key but what is required in place of 'fake_app'. I've main.py where I've created the application.

def main():
    # Create a Django application for WSGI.
    application = django.core.handlers.wsgi.WSGIHandler()

    # Run the WSGI CGI handler with that application.
    util.run_wsgi_app(application)

if __name__ == '__main__':
    main()

Do I need this application instance to pass in place of fake_app? I'm new to this and do not understand the functionality properly. Please if anyone could explain also.

Upvotes: 0

Views: 411

Answers (2)

Kenny Meyer
Kenny Meyer

Reputation: 8027

It is just an anonymous function.

I have taken a look at the gae-sessions source, and what I found for fake-app is this:

[snip]

class DjangoSessionMiddleware(object):
    def __init__(self):
        fake_app = lambda environ, start_response : start_response
        self.wrapped_wsgi_middleware = SessionMiddleware(fake_app, cookie_key='you MUST change this')

[snip]

Basically the class DjangoSessionMiddleware is just a wrapper.

So, this means you don't have to modify fake_app, because it's needed for SessionMiddleware, but only change change the value of cookie_key.

Upvotes: 1

emirc
emirc

Reputation: 2018

Did you create appengine_config.py?

It's pretty straightforward and it is described in: https://github.com/dound/gae-sessions/blob/master/README.markdown

HTH...

Upvotes: 0

Related Questions