sleach
sleach

Reputation: 11

How to access the session object in Django Syndication framework code

Quick question. In my syndication feed framework code,

http://docs.djangoproject.com/en/dev/ref/contrib/syndication/

what is the best way to get access to the session? I don't have access to the request, and I can't use

from django.contrib.sessions.backends.db import SessionStore 

as I don't know the session ID, but I need to access some of the variables in the session.

i.e. I have:

from django.contrib.syndication.feeds import Feed
class LatestPhotos(Feed):
    ...

and in that LatestPhotos class, I need to access something in the session to help control the logic flow. I can't find any documentation on the best way to do it.

Thanks

Thanks!

Upvotes: 1

Views: 840

Answers (2)

sleach
sleach

Reputation: 11

Figured it out - drrr, so simple. The syndication framework Feed class has a member called request...so simple I never thought of it :)

[this comment applies to django 1.1 and earlier syndication framework]

Upvotes: 0

John Weldon
John Weldon

Reputation: 40789

It seems like a design flaw to be trying to access session data in the LatestPhoto's class. I would assume that if your syndication feed depended on a session variable, then the items you're syndicating (LatestPhotos) should be constructed with that variable?

Can you make the logic flow decision before you construct the LatestPhotos object, or at the very least pass the session ID in to the LatestPhotos init routine?

Upvotes: 2

Related Questions