Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes
plone.app.portlets.portlets.rss.RSSFeed Class Reference

List of all members.

Public Member Functions

def __init__
def last_update_time_in_minutes
def last_update_time
def update_failed
def ok
def loaded
def needs_update
def update
def items
def feed_link
def title
def siteurl

Public Attributes

 url
 timeout

Static Public Attributes

int FAILURE_DELAY = 10

Private Member Functions

def _retrieveFeed

Private Attributes

 _items
 _title
 _siteurl
 _loaded
 _failed
 _last_update_time_in_minutes
 _last_update_time

Detailed Description

an RSS feed

Definition at line 69 of file rss.py.


Constructor & Destructor Documentation

def plone.app.portlets.portlets.rss.RSSFeed.__init__ (   self,
  url,
  timeout 
)

Definition at line 76 of file rss.py.

00076 
00077     def __init__(self, url, timeout):
00078         self.url = url
00079         self.timeout = timeout
00080         
00081         self._items = []
00082         self._title = ""
00083         self._siteurl = ""
00084         self._loaded = False    # is the feed loaded
00085         self._failed = False    # does it fail at the last update?
00086         self._last_update_time_in_minutes = 0 # when was the feed last updated?
00087         self._last_update_time = None            # time as DateTime or Nonw

Here is the caller graph for this function:


Member Function Documentation

do the actual work and try to retrieve the feed

Definition at line 134 of file rss.py.

00134 
00135     def _retrieveFeed(self):
00136         """do the actual work and try to retrieve the feed"""
00137         url = self.url
00138         if url!='':
00139             self._last_update_time_in_minutes = time.time()/60
00140             self._last_update_time = DateTime()
00141             d = feedparser.parse(url)
00142             if d.bozo==1:
00143                 self._loaded = True # we tried at least but have a failed load
00144                 self._failed = True
00145                 return False
00146             self._title = d.feed.title
00147             self._siteurl = d.feed.link
00148             self._items = []
00149             for item in d['items']:
00150                 try:
00151                     link = item.links[0]['href']
00152                     itemdict = {
00153                         'title' : item.title,
00154                         'url' : link,
00155                         'summary' : item.get('description',''),
00156                     }
00157                     if hasattr(item, "updated"):
00158                         itemdict['updated']=DateTime(item.updated)
00159                 except AttributeError:
00160                     continue
00161                 self._items.append(itemdict)
00162             self._loaded = True
00163             self._failed = False
00164             return True
00165         self._loaded = True
00166         self._failed = True # no url set means failed 
00167         return False # no url set, although that actually should not really happen
00168 
        

Here is the caller graph for this function:

return rss url of feed for portlet

Definition at line 177 of file rss.py.

00177 
00178     def feed_link(self):
00179         """return rss url of feed for portlet"""
00180         return self.url.replace("http://","feed://")

Definition at line 170 of file rss.py.

00170 
00171     def items(self):
00172         return self._items

Here is the caller graph for this function:

return the time the last update was done in minutes

Definition at line 94 of file rss.py.

00094 
00095     def last_update_time(self):
00096         """return the time the last update was done in minutes"""
00097         return self._last_update_time

return the time the last update was done in minutes

Definition at line 89 of file rss.py.

00089 
00090     def last_update_time_in_minutes(self):
00091         """return the time the last update was done in minutes"""
00092         return self._last_update_time_in_minutes

Here is the caller graph for this function:

return whether this feed is loaded or not

Definition at line 107 of file rss.py.

00107 
00108     def loaded(self):
00109         """return whether this feed is loaded or not"""
00110         return self._loaded
        
check if this feed needs updating

Definition at line 112 of file rss.py.

00112 
00113     def needs_update(self):
00114         """check if this feed needs updating"""
00115         now = time.time()/60
00116         return (self.last_update_time_in_minutes+self.timeout) < now
        

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 103 of file rss.py.

00103 
00104     def ok(self):
00105         return (not self._failed and self._loaded)
        

Here is the caller graph for this function:

return the link to the site the RSS feed points to

Definition at line 187 of file rss.py.

00187 
00188     def siteurl(self):
00189         """return the link to the site the RSS feed points to"""
00190         return self._siteurl

return title of feed for portlet

Definition at line 182 of file rss.py.

00182 
00183     def title(self):
00184         """return title of feed for portlet"""
00185         return self._title
    

Here is the caller graph for this function:

update this feed

Definition at line 117 of file rss.py.

00117 
00118     def update(self):
00119         """update this feed"""
00120         now = time.time()/60    # time in minutes
00121          
00122         # check for failure and retry
00123         if self.update_failed:
00124             if (self.last_update_time_in_minutes+self.FAILURE_DELAY) < now:
00125                 return self._retrieveFeed()
00126             else:
00127                 return False
00128 
00129         # check for regular update
00130         if self.needs_update:
00131             return self._retrieveFeed()
00132             
00133         return self.ok

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 99 of file rss.py.

00099 
00100     def update_failed(self):
00101         return self._failed

Here is the caller graph for this function:


Member Data Documentation

Definition at line 84 of file rss.py.

Definition at line 80 of file rss.py.

Definition at line 86 of file rss.py.

Definition at line 85 of file rss.py.

Definition at line 83 of file rss.py.

Definition at line 82 of file rss.py.

Definition at line 81 of file rss.py.

an RSS feed

Definition at line 74 of file rss.py.

Definition at line 78 of file rss.py.

Definition at line 77 of file rss.py.


The documentation for this class was generated from the following file: