comparison MoinMoin/action/rss_rc.py @ 4176:85884c67228d

Replaced/removed calls to request.emit_http_headers
author Florian Krupicka <florian.krupicka@googlemail.com>
date Wed, 18 Jun 2008 00:28:07 +0200
parents a739558ca3dc
children fc20a076aad0
comparison
equal deleted inserted replaced
4175:5bcd612588fc 4176:85884c67228d
22 22
23 def execute(pagename, request): 23 def execute(pagename, request):
24 """ Send recent changes as an RSS document 24 """ Send recent changes as an RSS document
25 """ 25 """
26 if not wikixml.ok: 26 if not wikixml.ok:
27 httpheaders = ["Content-Type: text/plain; charset=%s" % config.charset] 27 request.response.mimetype = 'text/plain'
28 request.emit_http_headers(httpheaders)
29 request.write("rss_rc action is not supported because of missing pyxml module.") 28 request.write("rss_rc action is not supported because of missing pyxml module.")
30 return 29 return
31 30
32 cfg = request.cfg 31 cfg = request.cfg
33 32
84 # for 304, we look at if-modified-since and if-none-match headers, 83 # for 304, we look at if-modified-since and if-none-match headers,
85 # one of them must match and the other is either not there or must match. 84 # one of them must match and the other is either not there or must match.
86 if request.if_modified_since == timestamp: 85 if request.if_modified_since == timestamp:
87 if request.if_none_match: 86 if request.if_none_match:
88 if request.if_none_match == etag: 87 if request.if_none_match == etag:
89 request.emit_http_headers(["Status: 304 Not modified"]) 88 request.response.status_code = 304
90 else: 89 else:
91 request.emit_http_headers(["Status: 304 Not modified"]) 90 request.response.status_code = 304
92 elif request.if_none_match == etag: 91 elif request.if_none_match == etag:
93 if request.if_modified_since: 92 if request.if_modified_since:
94 if request.if_modified_since == timestamp: 93 if request.if_modified_since == timestamp:
95 request.emit_http_headers(["Status: 304 Not modified"]) 94 request.response.status_code = 304
96 else: 95 else:
97 request.emit_http_headers(["Status: 304 Not modified"]) 96 request.response.status_code = 304
98 else: 97 else:
99 # generate an Expires header, using whatever setting the admin 98 # generate an Expires header, using whatever setting the admin
100 # defined for suggested cache lifetime of the RecentChanges RSS doc 99 # defined for suggested cache lifetime of the RecentChanges RSS doc
101 expires = timefuncs.formathttpdate(time.time() + cfg.rss_cache) 100 expires = time.time() + cfg.rss_cache
102 101
103 httpheaders = ["Content-Type: text/xml; charset=%s" % config.charset, 102 request.response.mime_type = 'text/xml'
104 "Expires: %s" % expires, 103 request.response.expires = expires
105 "Last-Modified: %s" % timestamp, 104 request.response.last_modified = lastmod
106 "Etag: %s" % etag, ] 105 request.response.headers.add('Etag', etag)
107 106
108 # send the generated XML document 107 # send the generated XML document
109 request.emit_http_headers(httpheaders)
110
111 baseurl = request.getBaseURL() 108 baseurl = request.getBaseURL()
112 if not baseurl.endswith('/'): 109 if not baseurl.endswith('/'):
113 baseurl += '/' 110 baseurl += '/'
114 111
115 logo = re.search(r'src="([^"]*)"', cfg.logo_string) 112 logo = re.search(r'src="([^"]*)"', cfg.logo_string)