Fixed #10141 -- Added a missing import to the complex Feed example. Thanks to Temoto for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9858 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
16d67a11ac
commit
b77bf5291a
|
@ -143,7 +143,7 @@ into those elements.
|
|||
|
||||
* ``{{ obj }}`` -- The current object (one of whichever objects you
|
||||
returned in :meth:`items()`).
|
||||
|
||||
|
||||
* ``{{ site }}`` -- A :class:`django.contrib.sites.models.Site` object
|
||||
representing the current site. This is useful for ``{{ site.domain
|
||||
}}`` or ``{{ site.name }}``. If you do *not* have the Django sites
|
||||
|
@ -181,9 +181,9 @@ into those elements.
|
|||
{{ obj.title }}
|
||||
|
||||
* latest_description.html:
|
||||
|
||||
|
||||
.. code-block:: html+django
|
||||
|
||||
|
||||
{{ obj.description }}
|
||||
|
||||
.. _chicagocrime.org: http://www.chicagocrime.org/
|
||||
|
@ -213,6 +213,7 @@ the feed.
|
|||
An example makes this clear. Here's the code for these beat-specific feeds::
|
||||
|
||||
from django.contrib.syndication.feeds import FeedDoesNotExist
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
class BeatFeed(Feed):
|
||||
def get_object(self, bits):
|
||||
|
@ -278,9 +279,9 @@ request to the URL :file:`/rss/beats/0613/`:
|
|||
|
||||
* First, it tries to call a method, passing the ``obj`` argument, where
|
||||
``obj`` is the object returned by :meth:`get_object()`.
|
||||
|
||||
|
||||
* Failing that, it tries to call a method with no arguments.
|
||||
|
||||
|
||||
* Failing that, it uses the class attribute.
|
||||
|
||||
Inside the :meth:`link()` method, we handle the possibility that ``obj``
|
||||
|
@ -840,11 +841,11 @@ They share this interface:
|
|||
|
||||
Initialize the feed with the given dictionary of metadata, which applies to
|
||||
the entire feed. Required keyword arguments are:
|
||||
|
||||
|
||||
* ``title``
|
||||
* ``link``
|
||||
* ``description``
|
||||
|
||||
|
||||
There's also a bunch of other optional keywords:
|
||||
|
||||
* ``language``
|
||||
|
@ -857,7 +858,7 @@ They share this interface:
|
|||
* ``feed_copyright``
|
||||
* ``feed_guid``
|
||||
* ``ttl``
|
||||
|
||||
|
||||
Any extra keyword arguments you pass to ``__init__`` will be stored in
|
||||
``self.feed`` for use with `custom feed generators`_.
|
||||
|
||||
|
@ -866,7 +867,7 @@ They share this interface:
|
|||
|
||||
.. method:: SyndicationFeed.add_item(**kwargs)
|
||||
|
||||
Add an item to the feed with the given parameters.
|
||||
Add an item to the feed with the given parameters.
|
||||
|
||||
Required keyword arguments are:
|
||||
|
||||
|
@ -893,7 +894,7 @@ They share this interface:
|
|||
|
||||
* ``pubdate`` should be a `Python datetime object`_.
|
||||
* ``enclosure`` should be an instance of ``feedgenerator.Enclosure``.
|
||||
* ``categories`` should be a sequence of Unicode objects.
|
||||
* ``categories`` should be a sequence of Unicode objects.
|
||||
|
||||
.. method:: SyndicationFeed.write(outfile, encoding)
|
||||
|
||||
|
@ -927,7 +928,7 @@ Custom feed generators
|
|||
----------------------
|
||||
|
||||
If you need to produce a custom feed format, you've got a couple of options.
|
||||
|
||||
|
||||
If the feed format is totally custom, you'll want to subclass
|
||||
``SyndicationFeed`` and completely replace the ``write()`` and
|
||||
``writeString()`` methods.
|
||||
|
@ -938,25 +939,25 @@ feeds typically add extra elements and/or attributes to the underlying format,
|
|||
and there are a set of methods that ``SyndicationFeed`` calls to get these extra
|
||||
attributes. Thus, you can subclass the appropriate feed generator class
|
||||
(``Atom1Feed`` or ``Rss201rev2Feed``) and extend these callbacks. They are:
|
||||
|
||||
|
||||
.. _georss: http://georss.org/
|
||||
.. _itunes podcast format: http://www.apple.com/itunes/store/podcaststechspecs.html
|
||||
|
||||
``SyndicationFeed.root_attributes(self, )``
|
||||
Return a ``dict`` of attributes to add to the root feed element
|
||||
(``feed``/``channel``).
|
||||
|
||||
|
||||
``SyndicationFeed.add_root_elements(self, handler)``
|
||||
Callback to add elements inside the root feed element
|
||||
(``feed``/``channel``). ``handler`` is an `XMLGenerator`_ from Python's
|
||||
built-in SAX library; you'll call methods on it to add to the XML
|
||||
document in process.
|
||||
|
||||
|
||||
``SyndicationFeed.item_attributes(self, item)``
|
||||
Return a ``dict`` of attributes to add to each item (``item``/``entry``)
|
||||
element. The argument, ``item``, is a dictionary of all the data passed to
|
||||
``SyndicationFeed.add_item()``.
|
||||
|
||||
|
||||
``SyndicationFeed.add_item_elements(self, handler, item)``
|
||||
Callback to add elements to each item (``item``/``entry``) element.
|
||||
``handler`` and ``item`` are as above.
|
||||
|
@ -973,7 +974,7 @@ For example, you might start implementing an iTunes RSS feed generator like so::
|
|||
attrs = super(iTunesFeed, self).root_attributes()
|
||||
attrs['xmlns:itunes'] = 'http://www.itunes.com/dtds/podcast-1.0.dtd'
|
||||
return attrs
|
||||
|
||||
|
||||
def add_root_elements(self, handler):
|
||||
super(iTunesFeed, self).add_root_elements(handler)
|
||||
handler.addQuickElement('itunes:explicit', 'clean')
|
||||
|
|
Loading…
Reference in New Issue