On Fri, 2006-07-21 at 23:25 -0700, afarnham wrote:
> I am messing with feeds for the first time with Django and was
> wondering if there is anyway to do authentication (i.e. grab the
> session) from inside the my Feed class? I followed the high level
> framework example from the documentation page if that helps in
> understanding how I implemented this feed.

You can't do this directly, but it's fairly easy to work around so that
you can get the request. At the moment, your urlpatterns setup will
contain a call to the function 'django.contrib.syndication.views.feed'.
If you have a look at that function in the source, you'll see it's
pretty simple and just basically looks up the right function from your
feed dictionary to call and passes it some parameters.

You want to change the parameters that are passed to your side. So copy
the feed() function from contrib/syndication/views.py to somewhere in
your own application. Change the parameters it passes to you (the line
that says "feedgen = f(slug, request.path).get_feed(param)" -- maybe
alter request.path to be request, perhaps ). Then set up the __init__
method on your subclass of the Feed class so that it accepts the new
parameters and converts them into the expected parameters for calling
Feed.__init__ (don't forget to call that method). For example, if you
were now passing 'request' to you __init__, you would need to remember
to still pass request.path to Feed.__init__. Then you can do whatever
you like with the 'request' object in your __init__ method (including
saving it for later use in the class).

Finally, change your urlpatterns to call your new view function instead
of the syndication.views.feed version.

OK, that's a pretty rough sketch, but should give you something to work
with. It's maybe four lines of code in total after copying the file, so
the explanation is longer than the change you have to make.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to