如何在Django Syndication Framework代码中访问会话对象 [英] 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/
最好的方法是可以访问该会话?我没有
访问该请求,也无法使用django.contrib.sessions中的
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
因为我不知道会话ID,但我需要访问会话中的某些
变量。
as I don't know the session ID, but I need to access some of the variables in the session.
即我有:
from django.contrib.syndication.feeds import Feed
class LatestPhotos(Feed):
...
,在该LatestPhotos类中,我需要访问会话中的某些内容以帮助控制逻辑流程。我找不到最佳方法的任何文档。
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.
谢谢
谢谢!
推荐答案
试图访问LatestPhoto类中的会话数据似乎是设计缺陷。我认为,如果您的联合供稿依赖于会话变量,那么您要联合的项目( LatestPhotos
)应该使用该变量构造吗?
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?
在构造 LatestPhotos
对象之前,您是否可以做出逻辑流程决定,或者至少将会话ID传递给 LatestPhotos
初始化例程?
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?
这篇关于如何在Django Syndication Framework代码中访问会话对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!