# HG changeset patch # User Paul Boddie # Date 1342477350 -7200 # Node ID 488bede7c02655a9329eb13247d3f89da56416da # Parent e6e47bf566cb923722f39bde2cb851d40235dd23 Moved remote resource management to the MoinRemoteSupport module in MoinSupport. Updated the release notes. diff -r e6e47bf566cb -r 488bede7c026 EventAggregatorSupport.py --- a/EventAggregatorSupport.py Sun Jul 15 22:42:28 2012 +0200 +++ b/EventAggregatorSupport.py Tue Jul 17 00:22:30 2012 +0200 @@ -10,18 +10,18 @@ from LocationSupport import * from MoinDateSupport import * +from MoinRemoteSupport import * from MoinSupport import * from MoinMoin.Page import Page -from MoinMoin.action import AttachFile, cache -from MoinMoin import caching +from MoinMoin.action import AttachFile from MoinMoin import search from MoinMoin import wikiutil import codecs import time import re -import urllib, urllib2 +import urllib try: from cStringIO import StringIO @@ -1046,52 +1046,10 @@ else: continue - # See if the URL is cached. - - cache_key = cache.key(request, content=url) - cache_entry = caching.CacheEntry(request, "EventAggregator", cache_key, scope='wiki') - - # If no entry exists, or if the entry is older than a certain age - # (5 minutes by default), create one with the response from the URL. - - now = time.time() - mtime = cache_entry.mtime() + # Obtain the resource, using a cached version if appropriate. + max_cache_age = int(getattr(request.cfg, "event_aggregator_max_cache_age", "300")) - - # NOTE: The URL could be checked and the 'If-Modified-Since' header - # NOTE: (see MoinMoin.action.pollsistersites) could be checked. - - if not cache_entry.exists() or now - mtime >= max_cache_age: - - # Access the remote data source. - - cache_entry.open(mode="w") - - try: - f = urllib2.urlopen(url) - try: - cache_entry.write(url + "\n") - cache_entry.write((f.headers.get("content-type") or "") + "\n") - cache_entry.write(f.read()) - finally: - cache_entry.close() - f.close() - - # In case of an exception, just ignore the remote source. - # NOTE: This could be reported somewhere. - - except IOError: - if cache_entry.exists(): - cache_entry.remove() - continue - - # Open the cache entry and read it. - - cache_entry.open() - try: - data = cache_entry.read() - finally: - cache_entry.close() + data = getCachedResource(request, url, "EventAggregator", "wiki", max_cache_age) # Process the entry, parsing the content. diff -r e6e47bf566cb -r 488bede7c026 README.txt --- a/README.txt Sun Jul 15 22:42:28 2012 +0200 +++ b/README.txt Tue Jul 17 00:22:30 2012 +0200 @@ -323,6 +323,8 @@ unknown location is to be specified. * The EventLocationsDict or equivalent can now retain time zone/regime information about each location. + * Added an event parser that can format special page regions in different + ways. New in EventAggregator 0.8.3 (Changes since EventAggregator 0.8.2) ------------------------------------------------------------------