minou
minou

Reputation: 16563

errors with gae-sessions and nose

I'm running into a few problems with adding gae-sessions to a relatively mature GAE app. I followed the readme carefully and also looked at the demo.

First, just adding the gaesesions directory to my app causes the following error when running tests with nose and nose-gae:

Exception ImportError: 'No module named threading' in <bound method local.__del__ of <_threading_local.local object at 0x103e10628>> ignored

All the tests run fine so not a big problem but suggests that something isn't right.

Next, if I add the following two lines of code:

from gaesessions import get_current_session
session = get_current_session()

And run my tests, then I get the following error:

Traceback (most recent call last):
  File "/Users/.../unit_tests.py", line 1421, in testParseFBRequest
    data = tasks.parse_fb_request(sr)
  File "/Users/.../tasks.py", line 220, in parse_fb_request
    session = get_current_session()
  File "/Users/.../gaesessions/__init__.py", line 36, in get_current_session
    return _tls.current_session
  File "/Library/.../python2.7/_threading_local.py", line 193, in __getattribute__
    return object.__getattribute__(self, name)
AttributeError: 'local' object has no attribute 'current_session'

This error does not happen on the dev server.

Any suggestions on fixing the above would be greatly appreciated.

Upvotes: 3

Views: 278

Answers (1)

Stefan
Stefan

Reputation: 744

I ran into the same problem. The problem seems to be that the gae testbed behaves differently than the development server. I don't know the specifics but ended up solving it by adding

def setUp(self):
  testbed.Testbed().activate()
  # after activating the testbed:
  from gaesessions import Session, set_current_session
  set_current_session(Session())

Upvotes: 3

Related Questions