joerussbowman / gaeutilities

gaeutilities - A collection of utilities to help with application development on Google Appengine
http://gaeutilities.appspot.com
BSD 3-Clause "New" or "Revised" License
78 stars 4 forks source link

Django middleware seems to be incomplete #8

Closed carlosble closed 14 years ago

carlosble commented 14 years ago

Hi! Thanks for gae_utitlities, they are great man! :-)

I've had to change the Django SessionMiddleware myself in order to make it work properly. The change was just adding this method:

def process_response(self, request, response):
        if hasattr(request, "session"):
           response.cookies= request.session.output_cookie

To the SessionMiddelware class under django-middelware/middelware.py

Now it works pretty well. Cheers

joerussbowman commented 14 years ago

What version of Django required this? I can add it no problem, but just curious.

joerussbowman commented 14 years ago

Suggested change is in, when I get more time I want to look if it should return None if the session attribute doesn't exist.

carlosble commented 14 years ago

I am using latest django version, 1.1.1

Thanks :-)

joerussbowman commented 14 years ago

ok thanks... for anyone using Django 1.1+, grab the master version to get this change. As I said, when I have more time I will double check the return value requirements for the middleware.

carlosble commented 14 years ago

Ok mate, I'll be aware of new versions that you might release. Please update this issue if you apply changes to the middleware so that I can be aware of it.

joerussbowman commented 14 years ago

Hi carlosble, if you get a chance can you confirm the latest update doesn't break anything? I modified it to return None for process_request, and the response object for process_presponse, per the Django Middleware documentation.

joerussbowman commented 14 years ago

closing due to lack of response

carlosble commented 14 years ago

Sorry Joe, couldn't try it out till now. It is working fine apparently. Why are the test methods assigned in every request? Wouldn't if affect performance?

Thanks

joerussbowman commented 14 years ago

I modeled it after the current django session middleware. It shouldn't affect performance much if it at all as it's a simple string check without any regex or anything. I suppose it could be optimized, but I'll leave that for anyone who is interested in taking that on.