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
|
self.__rss_webMaster = webMaster
|
||||||
return self.__rss_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
|
'''This method will add a new entry to the feed. If the feedEntry
|
||||||
argument is omittet a new Entry object is created automatically. This
|
argument is omittet a new Entry object is created automatically. This
|
||||||
is the prefered way to add new entries to a feed.
|
is the prefered way to add new entries to a feed.
|
||||||
|
|
||||||
:param feedEntry: FeedEntry object to add.
|
: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.
|
:returns: FeedEntry object created or passed to this function.
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
@ -1030,7 +1033,10 @@ class FeedGenerator(object):
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.__feed_entries.insert(0, feedEntry)
|
if order == 'prepend':
|
||||||
|
self.__feed_entries.insert(0, feedEntry)
|
||||||
|
else:
|
||||||
|
self.__feed_entries.append(feedEntry)
|
||||||
return feedEntry
|
return feedEntry
|
||||||
|
|
||||||
def add_item(self, item=None):
|
def add_item(self, item=None):
|
||||||
|
|
Loading…
Reference in a new issue