1
# -*- coding: iso-8859-1 -*-
3
MoinMoin - "pollsistersites" action
5
This action fetches lists of page urls and page names from sister sites,
6
so we can implement SisterWiki functionality.
7
See: http://usemod.com/cgi-bin/mb.pl?SisterSitesImplementationGuide
9
@copyright: 2007 MoinMoin:ThomasWaldmann
10
@license: GNU GPL, see COPYING for details.
15
from MoinMoin import caching
16
from MoinMoin.util import timefuncs
18
def execute(pagename, request):
20
for sistername, sisterurl in request.cfg.sistersites:
23
cache = caching.CacheEntry(request, arena, key, scope='farm', use_pickle=True)
25
data = cache.content()
27
data = {'lastmod': ''}
28
uo = urllib.URLopener()
29
uo.version = 'MoinMoin SisterPage list fetcher 1.0'
30
lastmod = data['lastmod']
32
uo.addheader('If-Modified-Since', lastmod)
35
f = uo.open(sisterurl)
39
page_url, page_name = line.split(' ', 1)
40
sisterpages[page_name.decode('utf-8')] = page_url
42
pass # ignore invalid lines
44
lastmod = f.info()["Last-Modified"]
46
lastmod = timefuncs.formathttpdate(time.time())
48
data['lastmod'] = lastmod
49
data['sisterpages'] = sisterpages
51
status.append(u"Site: %s Status: Updated. Pages: %d" % (sistername, len(sisterpages)))
52
except IOError, (title, code, msg, headers): # code e.g. 304
53
status.append(u"Site: %s Status: Not updated." % sistername)
54
except TypeError: # catch bug in python 2.5: "EnvironmentError expected at most 3 arguments, got 4"
55
status.append(u"Site: %s Status: Not updated." % sistername)
57
request.emit_http_headers(["Content-Type: text/plain; charset=UTF-8"])
58
request.write("\r\n".join(status).encode("utf-8"))