annotate MoinMoin/action/sisterpages.py @ 5250:00ca621ffbc2 1.9.0rc1

updated underlay
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 03 Nov 2009 00:40:45 +0100
parents 87d97510de79
children 1dff6cfdcf90
rev   line source
1787
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - "sisterpages" action
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 This action generates a list of page urls and page names, so that other wikis
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6 can implement SisterWiki functionality easily.
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 See: http://usemod.com/cgi-bin/mb.pl?SisterSitesImplementationGuide
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
8
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1788
diff changeset
9 @copyright: 2007 MoinMoin:ThomasWaldmann
1787
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10 @license: GNU GPL, see COPYING for details.
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 """
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13 import time
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15 from MoinMoin import wikiutil
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16 from MoinMoin.Page import Page
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17 from MoinMoin.util import timefuncs
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 from MoinMoin.logfile import editlog
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 def execute(pagename, request):
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21 log = editlog.EditLog(request)
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22 try:
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23 lastmod = wikiutil.version2timestamp(log.date())
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 except:
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
25 lastmod = 0
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27 timestamp = timefuncs.formathttpdate(lastmod)
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
28 etag = "%d" % lastmod
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 # for 304, we look at if-modified-since and if-none-match headers,
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31 # one of them must match and the other is either not there or must match.
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 if request.if_modified_since == timestamp:
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 if request.if_none_match:
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 if request.if_none_match == etag:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
35 request.status_code = 304
1787
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 else:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
37 request.status_code = 304
1787
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 elif request.if_none_match == etag:
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 if request.if_modified_since:
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40 if request.if_modified_since == timestamp:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
41 request.status_code = 304
1787
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42 else:
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
43 request.status_code = 304
1787
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44 else:
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45 # generate an Expires header, using 1d cache lifetime of sisterpages list
4176
85884c67228d Replaced/removed calls to request.emit_http_headers
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3234
diff changeset
46 expires = time.time() + 24*3600
1787
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47
4183
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
48 request.mime_type = 'text/plain'
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
49 request.expires = expires
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
50 request.last_modified = timestamp
fc20a076aad0 Accomodate for consolidation of Request/Response
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
51 request.headers.add("Etag", etag)
1787
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
52
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
53 # send the generated XML document
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
54 # Get list of user readable pages
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
55 pages = request.rootpage.getPageList()
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
56 pages.sort()
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
57 for pn in pages:
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
58 p = Page(request, pn)
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
59 entry = u"%s %s\r\n" % (request.getQualifiedURL(p.url(request)), p.page_name)
1787
f4a941fe32f8 added SisterSites/SisterPages support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
60 request.write(entry.encode('utf-8'))