toastdriven/django-tastypie — pull request #331 by eykd (2012-01-13 18:59:24+00:00)
Title: Added SessionMiddleware subclass to suppress sessions in API calls

In reference to #330, this change adds the ability to suppress sessions for resource requests, if the Django sessions framework is enabled for a site.

Highlights:

- a new middleware class, `tastypie.middleware.ApiSessionMiddleware`, a subclass of `django.contrib.sessions.SessionMiddleware`.

- The new middleware optionally suppresses sessions for Resource requests based on `settings.API_SUPPRESSES_SESSIONS` or `ResourceOptions.suppress_sessions`. Sessions will behave normally for non-Resource requests.

- Sites not using the sessions framework, or using the default sessions middleware will not be affected.

- Documentation **is** included.

- Tests **are not** included--I'm not sure how to set up the test environment correctly for middleware. I have, however, tested the expected behavior manually in my own API project.