Changeset 6741
- Timestamp:
- 11/29/07 11:41:35 (9 months ago)
- Files:
-
- django/trunk/docs/syndication_feeds.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/syndication_feeds.txt
r6570 r6741 202 202 An example makes this clear. Here's the code for these beat-specific feeds:: 203 203 204 from django.contrib.syndication import FeedDoesNotExist 205 204 206 class BeatFeed(Feed): 205 207 def get_object(self, bits): … … 214 216 215 217 def link(self, obj): 218 if not obj: 219 raise FeedDoesNotExist 216 220 return obj.get_absolute_url() 217 221 … … 247 251 algorithm: 248 252 249 * First, it tries to call a method, passing the ``obj`` argument, where250 ``obj`` is the object returned by ``get_object()``.253 * First, it tries to call a method, passing the ``obj`` argument, 254 where ``obj`` is the object returned by ``get_object()``. 251 255 * Failing that, it tries to call a method with no arguments. 252 256 * Failing that, it uses the class attribute. 257 258 Inside the ``link()`` method, we handle the possibility that ``obj`` 259 might be ``None``, which can occur when the URL isn't fully specified. In 260 some cases, you might want to do something else in this case, which would 261 mean you'd need to check for ``obj`` existing in other methods as well 262 (the ``link()`` method is called very early in the feed generation 263 process, so is a good place to bail out early). 253 264 254 265 * Finally, note that ``items()`` in this example also takes the ``obj``
