简体   繁体   中英

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.

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 .

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM