1.1 --- a/EventAggregatorSupport.py Sun Jul 15 22:42:28 2012 +0200
1.2 +++ b/EventAggregatorSupport.py Tue Jul 17 00:22:30 2012 +0200
1.3 @@ -10,18 +10,18 @@
1.4
1.5 from LocationSupport import *
1.6 from MoinDateSupport import *
1.7 +from MoinRemoteSupport import *
1.8 from MoinSupport import *
1.9
1.10 from MoinMoin.Page import Page
1.11 -from MoinMoin.action import AttachFile, cache
1.12 -from MoinMoin import caching
1.13 +from MoinMoin.action import AttachFile
1.14 from MoinMoin import search
1.15 from MoinMoin import wikiutil
1.16
1.17 import codecs
1.18 import time
1.19 import re
1.20 -import urllib, urllib2
1.21 +import urllib
1.22
1.23 try:
1.24 from cStringIO import StringIO
1.25 @@ -1046,52 +1046,10 @@
1.26 else:
1.27 continue
1.28
1.29 - # See if the URL is cached.
1.30 -
1.31 - cache_key = cache.key(request, content=url)
1.32 - cache_entry = caching.CacheEntry(request, "EventAggregator", cache_key, scope='wiki')
1.33 -
1.34 - # If no entry exists, or if the entry is older than a certain age
1.35 - # (5 minutes by default), create one with the response from the URL.
1.36 -
1.37 - now = time.time()
1.38 - mtime = cache_entry.mtime()
1.39 + # Obtain the resource, using a cached version if appropriate.
1.40 +
1.41 max_cache_age = int(getattr(request.cfg, "event_aggregator_max_cache_age", "300"))
1.42 -
1.43 - # NOTE: The URL could be checked and the 'If-Modified-Since' header
1.44 - # NOTE: (see MoinMoin.action.pollsistersites) could be checked.
1.45 -
1.46 - if not cache_entry.exists() or now - mtime >= max_cache_age:
1.47 -
1.48 - # Access the remote data source.
1.49 -
1.50 - cache_entry.open(mode="w")
1.51 -
1.52 - try:
1.53 - f = urllib2.urlopen(url)
1.54 - try:
1.55 - cache_entry.write(url + "\n")
1.56 - cache_entry.write((f.headers.get("content-type") or "") + "\n")
1.57 - cache_entry.write(f.read())
1.58 - finally:
1.59 - cache_entry.close()
1.60 - f.close()
1.61 -
1.62 - # In case of an exception, just ignore the remote source.
1.63 - # NOTE: This could be reported somewhere.
1.64 -
1.65 - except IOError:
1.66 - if cache_entry.exists():
1.67 - cache_entry.remove()
1.68 - continue
1.69 -
1.70 - # Open the cache entry and read it.
1.71 -
1.72 - cache_entry.open()
1.73 - try:
1.74 - data = cache_entry.read()
1.75 - finally:
1.76 - cache_entry.close()
1.77 + data = getCachedResource(request, url, "EventAggregator", "wiki", max_cache_age)
1.78
1.79 # Process the entry, parsing the content.
1.80
2.1 --- a/README.txt Sun Jul 15 22:42:28 2012 +0200
2.2 +++ b/README.txt Tue Jul 17 00:22:30 2012 +0200
2.3 @@ -323,6 +323,8 @@
2.4 unknown location is to be specified.
2.5 * The EventLocationsDict or equivalent can now retain time zone/regime
2.6 information about each location.
2.7 + * Added an event parser that can format special page regions in different
2.8 + ways.
2.9
2.10 New in EventAggregator 0.8.3 (Changes since EventAggregator 0.8.2)
2.11 ------------------------------------------------------------------