1.1 --- a/macros/SharedContent.py Tue Jul 17 00:03:35 2012 +0200
1.2 +++ b/macros/SharedContent.py Tue Jul 17 00:41:14 2012 +0200
1.3 @@ -7,9 +7,14 @@
1.4 """
1.5
1.6 from MoinMoin.Page import Page
1.7 -import urllib
1.8 +from MoinRemoteSupport import *
1.9 import xml.dom.pulldom
1.10
1.11 +try:
1.12 + from cStringIO import StringIO
1.13 +except ImportError:
1.14 + from StringIO import StringIO
1.15 +
1.16 Dependencies = ["time"]
1.17
1.18 MAX_ENTRIES = 5
1.19 @@ -41,9 +46,16 @@
1.20 except IndexError:
1.21 pass
1.22
1.23 - # Obtain the feed.
1.24 + # Obtain the resource, using a cached version if appropriate.
1.25
1.26 - feed = urllib.urlopen(feed_url)
1.27 + max_cache_age = int(getattr(request.cfg, "moin_share_max_cache_age", "300"))
1.28 + data = getCachedResource(request, feed_url, "MoinShare", "wiki", max_cache_age)
1.29 + if not data:
1.30 + return fmt.text(_("SharedContent: updates could not be retrieved for %s") % feed_url)
1.31 +
1.32 + feed = StringIO(data)
1.33 + _url = feed.readline()
1.34 + _content_type = feed.readline()
1.35
1.36 try:
1.37 # Parse each node from the feed.