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.
Attachments (3)
Change History (17)
by , 17 years ago
Attachment: | appengine_session_backend.1.jezdez.diff added |
---|
comment:1 by , 17 years ago
Owner: | changed from | to
---|---|
Patch needs improvement: | set |
Status: | new → assigned |
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 , 17 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
by , 17 years ago
Attachment: | appengine_session_backend.2.jezdez.diff added |
---|
Fixed stupid conditional error
comment:3 by , 17 years ago
Owner: | set to |
---|---|
Patch needs improvement: | unset |
comment:4 by , 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 , 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 , 17 years ago
You could add a prefix string like 'session_key:' to the django generated id.
follow-up: 8 comment:7 by , 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 , 17 years ago
Attachment: | appengine_session_backend.3.jezdez.diff added |
---|
Uses session_key as key_name and Session.get_by_key_name() for better performance. Added session_key_prefix to circumvent BadArgumentError.
comment:8 by , 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 , 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 , 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:12 by , 17 years ago
Needs documentation: | set |
---|---|
Triage Stage: | Unreviewed → Someday/Maybe |
comment:13 by , 17 years ago
comment:14 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
I take this as a "Close this until one of those alternatives requests inclusion as a contrib app" ;)
first implementation, including documentation and tests