hitrust / google-app-engine-django

Automatically exported from code.google.com/p/google-app-engine-django
Apache License 2.0
0 stars 0 forks source link

'super' object has no attribute 'expire_date' #146

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. process request in a view
2. try to call _setitem_ on session like this: 'request.session['key'] = [val]

What is the expected output? What do you see instead?

I expect to see the template rendered by the view, but instead, I see a debug 
page with a backtrace:
Environment:

Request Method: GET
Request URL: http://localhost:8080/pub/
Django Version: 1.1.1
Python Version: 2.5.4
Installed Applications:
('appengine_django', 'openidgae', 'django.contrib.sessions', 'pub', 'fb')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'openidgae.middleware.OpenIDMiddleware')

Traceback:
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in 
get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Ben\Development\workspace\ringbot\src\pub\views.py" in index
  25.     request.session.set_expiry(0)
File "C:\Python25\lib\site-packages\django\contrib\sessions\backends\base.py" 
in set_expiry
  220.         self['_session_expiry'] = value
File "C:\Python25\lib\site-packages\django\contrib\sessions\backends\base.py" 
in __setitem__
  49.         self._session[key] = value
File "C:\Python25\lib\site-packages\django\contrib\sessions\backends\base.py" 
in _get_session
  172.                 self._session_cache = self.load()
File 
"C:\Users\Ben\Development\workspace\ringbot\src\appengine_django\sessions\backen
ds\db.py" in load
  29.     session = self._get_session(self.session_key)
File 
"C:\Users\Ben\Development\workspace\ringbot\src\appengine_django\sessions\backen
ds\db.py" in _get_session
  65.       if session.expire_date > datetime.now():
File "C:\Program 
Files\Google\google_appengine\google\appengine\ext\db\__init__.py" in 
__getattr__
  1396.       return getattr(super(Expando, self), key)

Exception Type: AttributeError at /pub/
Exception Value: 'super' object has no attribute 'expire_date'

What version of the product are you using? On what operating system?

django-1.1.1, google-app-engine-django r99 (first discovered in r95)

Please provide any additional information below.

As always, I am probably just doing something wrong, but I haven't yet been 
able to figure out what.

Original issue reported on code.google.com by aggie...@gmail.com on 29 Nov 2009 at 3:04

GoogleCodeExporter commented 9 years ago
It appears that openidgae has sessions models that stomp on django...

Original comment by aggie...@gmail.com on 29 Nov 2009 at 5:58

GoogleCodeExporter commented 9 years ago
I lose track of what's happening on 
appengine_django\sessions\backends\db.py:63.  The 
session_key is correct as best I can tell (and the datastore only has one 
session 
entity anyway), but what gets loaded here is an openidgae.models.Session 
instead of 
appengine_django.sessions.models.Session.  I have no idea why, and I'm not sure 
how to 
tell exactly which it is that's stored in the datastore.

Original comment by aggie...@gmail.com on 29 Nov 2009 at 6:19

GoogleCodeExporter commented 9 years ago
I can run this in the interactive console on /_ah/admin:

    from google.appengine.api import users
    from appengine_django.sessions.models import Session

    s = Session.all().get()
    print s.expire_date

The printed results are correct, so now I'm more confused.

Original comment by aggie...@gmail.com on 29 Nov 2009 at 6:21

GoogleCodeExporter commented 9 years ago
The problem does not appear to be with setting a value on the session. The 
problem 
is that the session object that is retrieved has no expire_date attribute, so 
the App 
Engine expando model code is raising an error when it tries to read it in the 
course 
of validating that the session is correct - before the attribute setting code 
is even 
touched.

How was your session data created? Maybe you have bogus data in your datastore?

Try clearing all your session models via the admin console.

Starting from a clean datastore can you provide a reproducible set of steps to 
demonstrate this issue?

Original comment by mattbrow...@gmail.com on 30 Nov 2009 at 12:46

GoogleCodeExporter commented 9 years ago
Ok .. I had the same problem and I figured it out. 
It's because you are using this project
http://code.google.com/p/google-app-engine-django-openid/
to implement openid functionality ... 
And it creates a model class Session that uses the same datastore table name as 
the
regular django Session model, but doesn't set the expire_date attribute. 
So as the result - you get records that have no expire_date .... 

To fix the issue, I just changed the name of openid's Session class to 
OpenIDSession,
and changed the code to reflect the change of class name 
(in the openid app Session is created in  2 places in __init__.py). 

So now it works ... 

Original comment by senad...@gmail.com on 18 Dec 2009 at 5:42

GoogleCodeExporter commented 9 years ago
Thanks a ton!  I knew the problem was in the openid project's Session class, 
but I 
wasn't able to get a simple reproduction of the problem working before I got 
busy 
again.  Thanks for your persistence!

Original comment by aggie...@gmail.com on 18 Dec 2009 at 3:16

GoogleCodeExporter commented 9 years ago

Original comment by mattbrow...@gmail.com on 4 Jan 2010 at 2:52