Closed GoogleCodeExporter closed 9 years ago
have you added the ThreadLocalsMiddleware to the middlewares in your
settings.py?
Original comment by herbert....@gmail.com
on 30 Sep 2009 at 12:12
Yes. These are my middlewares:
MIDDLEWARE_CLASSES = (
'jakakasa.sphene.community.middleware.ThreadLocals',
#'jakakasa.sphene.community.middleware.MultiHostMiddleware',
'jakakasa.sphene.community.middleware.GroupMiddleware',
#'jakakasa.sphene.community.middleware.StatsMiddleware',
#'jakakasa.sphene.community.middleware.LastModified',
#'jakakasa.sphene.community.middleware.PermissionDeniedMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
)
I have also tried with uncommented lines with same effect. The problem is in
'_thread_locals' (file community/middleware/py) - it does not have attribute
'request'.
Original comment by arr...@gmail.com
on 30 Sep 2009 at 12:25
well, it does have the attribute if the middleware is called correctly:
class ThreadLocals(object):
"""Middleware that gets various objects from the
request object and saves them in thread local storage."""
def process_request(self, request):
_thread_locals.request = request
_thread_locals.user = getattr(request, 'user', None)
_thread_locals.sphdata = { }
maybe the problem is, that you use a different import.. can you try adapting
your
python path so that you can use 'sphene.community.middleware.ThreadLocals' ?
Original comment by herbert....@gmail.com
on 30 Sep 2009 at 12:31
I think I found where is the problem. Class ThreadLocals create its own
instance of
_thread_locals variable. I checked id of _thread_locals before request
assignment and
get_current_request() and they are different.
I am using 2.6.2 under linux.
Original comment by arr...@gmail.com
on 30 Sep 2009 at 1:08
try changing the way you specify the class in MIDDLEWARE_CLASSES, and it should
be
the same instance ...
Original comment by herbert....@gmail.com
on 30 Sep 2009 at 1:11
You are right. After this change everything works fine.
Thanks a lot.
Original comment by arr...@gmail.com
on 30 Sep 2009 at 1:23
great :) i'll close the issue
Original comment by herbert....@gmail.com
on 30 Sep 2009 at 2:43
Original issue reported on code.google.com by
arr...@gmail.com
on 30 Sep 2009 at 12:06