added order parameter to add_entry()
Commit 7706033200
changed the order
in which new entries are added to a feed. This commit allows the
user to choose the order herself.
This commit is contained in:
parent
c92a340f88
commit
6aead0a7ac
1 changed files with 8 additions and 2 deletions
|
@ -995,12 +995,15 @@ class FeedGenerator(object):
|
|||
self.__rss_webMaster = webMaster
|
||||
return self.__rss_webMaster
|
||||
|
||||
def add_entry(self, feedEntry=None):
|
||||
def add_entry(self, feedEntry=None, order='prepend'):
|
||||
'''This method will add a new entry to the feed. If the feedEntry
|
||||
argument is omittet a new Entry object is created automatically. This
|
||||
is the prefered way to add new entries to a feed.
|
||||
|
||||
:param feedEntry: FeedEntry object to add.
|
||||
:param order: If `prepend` is chosen, the entry will be inserted
|
||||
at the beginning of the feed. If `append` is chosen,
|
||||
the entry will be appended to the feed. (default: `prepend`).
|
||||
:returns: FeedEntry object created or passed to this function.
|
||||
|
||||
Example::
|
||||
|
@ -1030,7 +1033,10 @@ class FeedGenerator(object):
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
if order == 'prepend':
|
||||
self.__feed_entries.insert(0, feedEntry)
|
||||
else:
|
||||
self.__feed_entries.append(feedEntry)
|
||||
return feedEntry
|
||||
|
||||
def add_item(self, item=None):
|
||||
|
|
Loading…
Reference in a new issue