1

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!

sleach
  • 11
  • 1

2 Answers2

2

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?

John Weldon
  • 39,849
  • 11
  • 94
  • 127
  • +1: Syndication is session-less. It's an announcement of site changes handed out to anyone who does a GET on /feeds/. There is neither session nor user. – S.Lott Jun 09 '09 at 21:31
  • The problem is, you have to provide a dict of url => Feed class mappings in your urls.py URL patterns definition. So I have no access whatsoever to the session at any point (or at least the request) so I can tell which "site" the request is for. This is defined at boot time, not at all during the request. Thoughts on how to do it given those constraints? Thanks! – sleach Jun 10 '09 at 12:48
  • Looks like someone else wants similar functionality: http://code.djangoproject.com/ticket/2912 – sleach Jun 10 '09 at 12:50
0

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]

Jure C.
  • 3,013
  • 28
  • 33
sleach
  • 11
  • 1