Opened 17 years ago

Closed 17 years ago

#7008 closed (invalid)

Add session backend for Google's App Engine

Reported by: Jannis Leidel Owned by: Jannis Leidel
Component: contrib.sessions Version: dev
Severity: Keywords: gae, appengine
Cc: Triage Stage: Someday/Maybe
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Now that the cheering stopped I started implementing a session backend for Google's App Engine, obviously the easiest part in creating more compatibility between Django and GAE.

Change History (17)

by Jannis Leidel, 17 years ago

first implementation, including documentation and tests

comment:1 by colinramsay, 17 years ago

Owner: changed from Jannis Leidel to colinramsay
Patch needs improvement: set
Status: newassigned

I think line 107 on your patch should be "if s:" rather than "if not s:", otherwise when a matching entry is found it will still raise SuspiciousOperation and reset the session.

comment:2 by colinramsay, 17 years ago

Owner: colinramsay removed
Status: assignednew

by Jannis Leidel, 17 years ago

Fixed stupid conditional error

comment:3 by Jannis Leidel, 17 years ago

Owner: set to Jannis Leidel
Patch needs improvement: unset

comment:4 by ribrdb <ribrdb@…>, 17 years ago

It would be more efficient to use the session_key as the key_name, and then use Session.get_by_key_name() instead of querying through Session.all()

comment:5 by Jannis Leidel, 17 years ago

Yes, I think so, too.

I had it implemented that way first but got "BadArgumentError: Names may not begin with a digit; received 838deafcd209c60564b730bb8b4f8fd1." exceptions from appengine and didn't want to change the way the session IDs are generated by Django.

What do you think?

comment:6 by ribrdb <ribrdb@…>, 17 years ago

You could add a prefix string like 'session_key:' to the django generated id.

comment:7 by ribrdb <ribrdb@…>, 17 years ago

Couldn't someone set settings.SESSION_COOKIE_NAME to something that starts with a number? That seems to be allowed by the RFC.

by Jannis Leidel, 17 years ago

Uses session_key as key_name and Session.get_by_key_name() for better performance. Added session_key_prefix to circumvent BadArgumentError.

in reply to:  7 comment:8 by Jannis Leidel, 17 years ago

Replying to ribrdb <ribrdb@gmail.com>:

Couldn't someone set settings.SESSION_COOKIE_NAME to something that starts with a number? That seems to be allowed by the RFC.

Right, I fixed that now :)

comment:9 by ribrdb, 17 years ago

I like it. It might be good though to add a test case to make sure you get the data back when you save and then load a session.

comment:10 by makovick, 17 years ago

AFAIK the App Engine has currently no equivalent of cron, so it would be nice if SessionStore.load is able to purge all expired sessions every once a while.
The purge timeout could be handled by the memcache API - after the cleanup, one can set some "sessions_purged" flag with 1 hour/day/whatever expiration, and then skip the purge until the flag disappears. This would avoid unnecessary datastore lookups.

comment:11 by Marc Fargas, 17 years ago

Brought to django-developers (here) for discussion.

comment:12 by Marc Fargas, 17 years ago

Needs documentation: set
Triage Stage: UnreviewedSomeday/Maybe

comment:14 by Marc Fargas, 17 years ago

Resolution: invalid
Status: newclosed

I take this as a "Close this until one of those alternatives requests inclusion as a contrib app" ;)

Note: See TracTickets for help on using tickets.
Back to Top