changeset 4183:fc20a076aad0

Accomodate for consolidation of Request/Response
author Florian Krupicka <florian.krupicka@googlemail.com>
date Sat, 21 Jun 2008 16:57:20 +0200
parents ca0cf44dab89
children b4acdce23cfa
files MoinMoin/Page.py MoinMoin/action/AttachFile.py MoinMoin/action/__init__.py MoinMoin/action/backup.py MoinMoin/action/links.py MoinMoin/action/pollsistersites.py MoinMoin/action/rss_rc.py MoinMoin/action/serveopenid.py MoinMoin/action/showtags.py MoinMoin/action/sisterpages.py MoinMoin/action/sitemap.py MoinMoin/action/titleindex.py MoinMoin/auth/http.py MoinMoin/session.py MoinMoin/stats/hitcounts.py MoinMoin/stats/pagesize.py MoinMoin/stats/useragents.py MoinMoin/xmlrpc/__init__.py
diffstat 18 files changed, 57 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/Page.py	Sat Jun 21 16:57:20 2008 +0200
@@ -964,13 +964,13 @@
             offer a dialogue to save it to disk (used by Save action).
         """
         request = self.request
-        request.response.mimetype = 'text/plain'
+        request.mimetype = 'text/plain'
         if self.exists():
             # use the correct last-modified value from the on-disk file
             # to ensure cacheability where supported. Because we are sending
             # RAW (file) content, the file mtime is correct as Last-Modified header.
-            request.response.status_code = 200
-            request.response.last_modified = os.path.getmtime(self._text_filename())
+            request.status_code = 200
+            request.last_modified = os.path.getmtime(self._text_filename())
             text = self.encodeTextMimeType(self.body)
             #request.setHttpHeader("Content-Length: %d" % len(text))  # XXX WRONG! text is unicode obj, but we send utf-8!
             if content_disposition:
@@ -978,9 +978,9 @@
                 # There is no solution that is compatible to IE except stripping non-ascii chars
                 filename_enc = "%s.txt" % self.page_name.encode(config.charset)
                 dispo_string = '%s; filename="%s"' % (content_disposition, filename_enc)
-                request.response.headers.add('Content-Disposition', dispo_string)
+                request.headers.add('Content-Disposition', dispo_string)
         else:
-            request.response.status_code = 404
+            request.status_code = 404
             text = u"Page %s not found." % self.page_name
 
         request.write(text)
@@ -1007,7 +1007,7 @@
         send_special = keywords.get('send_special', False)
         print_mode = keywords.get('print_mode', 0)
         if print_mode:
-            media = 'media' in request.form and request.form['media'][0] or 'print'
+            media = request.form.get('media', 'print')
         else:
             media = 'screen'
         self.hilite_re = (keywords.get('hilite_re') or
@@ -1076,12 +1076,12 @@
         page_exists = self.exists()
         if not content_only:
             if emit_headers:
-                request.response.content_type = "%s; charset=%s" % (self.output_mimetype, self.output_charset)
+                request.content_type = "%s; charset=%s" % (self.output_mimetype, self.output_charset)
                 if page_exists:
                     if not request.user.may.read(self.page_name):
-                        request.response.status_code = 403
+                        request.status_code = 403
                     else:
-                        request.response.status_code = 200
+                        request.status_code = 200
                     if not request.cacheable:
                         # use "nocache" headers if we're using a method that is not simply "display"
                         request.disableHttpCaching(level=2)
@@ -1096,7 +1096,7 @@
                         #request.setHttpHeader("Last-Modified: %s" % util.timefuncs.formathttpdate(lastmod))
                         pass
                 else:
-                    request.response.status_code = 404
+                    request.status_code = 404
 
             if not page_exists and self.request.isSpiderAgent:
                 # don't send any 404 content to bots
--- a/MoinMoin/action/AttachFile.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/action/AttachFile.py	Sat Jun 21 16:57:20 2008 +0200
@@ -809,7 +809,7 @@
     timestamp = os.path.getmtime(fpath)
     if_modified = time.mktime(request.if_modified_since.timetuple())
     if if_modified >= timestamp:
-        request.response.status_code = 304
+        request.status_code = 304
     else:
         mt = wikiutil.MimeType(filename=filename)
         content_type = mt.content_type()
@@ -825,11 +825,11 @@
         dangerous = mime_type in request.cfg.mimetypes_xss_protect
         content_dispo = dangerous and 'attachment' or 'inline'
 
-        request.response.content_type = content_type
-        request.response.last_modified = timestamp
-        request.response.content_length = os.path.getsize(fpath)
+        request.content_type = content_type
+        request.last_modified = timestamp
+        request.content_length = os.path.getsize(fpath)
         content_dispo_string = '%s; filename="%s"' % (content_dispo, filename_enc)
-        request.response.headers.add('Content-Disposition', content_dispo_string)
+        request.headers.add('Content-Disposition', content_dispo_string)
 
         # send data
         request.send_file(open(fpath, 'rb'))
--- a/MoinMoin/action/__init__.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/action/__init__.py	Sat Jun 21 16:57:20 2008 +0200
@@ -245,7 +245,8 @@
     if not request.user.may.read(pagename):
         Page(request, pagename).send_page()
     else:
-        mimetype = request.form.get('mimetype', [u"text/html"])[0]
+        from MoinMoin.web.contexts import HTTPContext, RenderContext
+        mimetype = request.form.get('mimetype', u"text/html")
         rev = request.rev or 0
         if rev == 0:
             request.cacheable = cacheable
@@ -269,8 +270,8 @@
 def do_content(pagename, request):
     """ same as do_show, but we only show the content """
     # XXX temporary fix to make it work until Page.send_page gets refactored
-    request.response.mimetype = 'text/html'
-    request.response.status_code = 200
+    request.mimetype = 'text/html'
+    request.status_code = 200
     do_show(pagename, request, count_hit=0, content_only=1)
 
 def do_print(pagename, request):
--- a/MoinMoin/action/backup.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/action/backup.py	Sat Jun 21 16:57:20 2008 +0200
@@ -29,9 +29,9 @@
     """ Send compressed tar file """
     dateStamp = time.strftime("%Y-%m-%d--%H-%M-%S-UTC", time.gmtime())
     filename = "%s-%s.tar.%s" % (request.cfg.siteid, dateStamp, request.cfg.backup_compression)
-    request.response.content_type = "application/octet-stream"
+    request.content_type = "application/octet-stream"
     dispo_string = 'inline; filename="%s"' % filename
-    request.response.headers.add('Content-Disposition', dispo_string)
+    request.headers.add('Content-Disposition', dispo_string)
 
     tar = tarfile.open(fileobj=request, mode="w|%s" % request.cfg.backup_compression)
     # allow GNU tar's longer file/pathnames
--- a/MoinMoin/action/links.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/action/links.py	Sat Jun 21 16:57:20 2008 +0200
@@ -19,7 +19,7 @@
     else:
         mimetype = "text/html"
 
-    request.response.mimetype = mimetype
+    request.mimetype = mimetype
 
     if mimetype == "text/html":
         request.theme.send_title(_('Full Link List for "%s"') % request.cfg.sitename)
--- a/MoinMoin/action/pollsistersites.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/action/pollsistersites.py	Sat Jun 21 16:57:20 2008 +0200
@@ -54,5 +54,5 @@
         except TypeError: # catch bug in python 2.5: "EnvironmentError expected at most 3 arguments, got 4"
             status.append(u"Site: %s Status: Not updated." % sistername)
 
-    request.response.mimetype = 'text/plain'
+    request.mimetype = 'text/plain'
     request.write("\r\n".join(status).encode("utf-8"))
--- a/MoinMoin/action/rss_rc.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/action/rss_rc.py	Sat Jun 21 16:57:20 2008 +0200
@@ -24,7 +24,7 @@
     """ Send recent changes as an RSS document
     """
     if not wikixml.ok:
-        request.response.mimetype = 'text/plain'
+        request.mimetype = 'text/plain'
         request.write("rss_rc action is not supported because of missing pyxml module.")
         return
 
@@ -85,24 +85,24 @@
     if request.if_modified_since == timestamp:
         if request.if_none_match:
             if request.if_none_match == etag:
-                request.response.status_code = 304
+                request.status_code = 304
         else:
-            request.response.status_code = 304
+            request.status_code = 304
     elif request.if_none_match == etag:
         if request.if_modified_since:
             if request.if_modified_since == timestamp:
-                request.response.status_code = 304
+                request.status_code = 304
         else:
-            request.response.status_code = 304
+            request.status_code = 304
     else:
         # generate an Expires header, using whatever setting the admin
         # defined for suggested cache lifetime of the RecentChanges RSS doc
         expires = time.time() + cfg.rss_cache
 
-        request.response.mime_type = 'text/xml'
-        request.response.expires = expires
-        request.response.last_modified = lastmod
-        request.response.headers.add('Etag', etag)
+        request.mime_type = 'text/xml'
+        request.expires = expires
+        request.last_modified = lastmod
+        request.headers.add('Etag', etag)
 
         # send the generated XML document
         baseurl = request.getBaseURL()
--- a/MoinMoin/action/serveopenid.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/action/serveopenid.py	Sat Jun 21 16:57:20 2008 +0200
@@ -31,7 +31,7 @@
 
     def serveYadisEP(self, endpoint_url):
         request = self.request
-        request.response.content_type = 'application/xrds+xml'
+        request.content_type = 'application/xrds+xml'
 
         user_url = request.getQualifiedURL(request.page.url(request))
         self.request.write("""\
@@ -78,7 +78,7 @@
 
     def serveYadisIDP(self, endpoint_url):
         request = self.request
-        request.response.content_type = 'application/xrds+xml'
+        request.content_type = 'application/xrds+xml'
 
         user_url = request.getQualifiedURL(request.page.url(request))
         self.request.write("""\
@@ -247,9 +247,9 @@
             else:
                 answer = openidsrv.handleRequest(openidreq)
         webanswer = openidsrv.encodeResponse(answer)
-        request.response.status = '%d OpenID status' % webanswer.code
+        request.status = '%d OpenID status' % webanswer.code
         for hdr in webanswer.headers:
-            request.response.headers.add(hdr, webanswer.headers[hdr])
+            request.headers.add(hdr, webanswer.headers[hdr])
         request.write(webanswer.body)
         raise MoinMoinFinish
 
--- a/MoinMoin/action/showtags.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/action/showtags.py	Sat Jun 21 16:57:20 2008 +0200
@@ -13,7 +13,7 @@
 from MoinMoin.wikisync import TagStore
 
 def execute(pagename, request):
-    request.response.mimetype = "text/plain"
+    request.mimetype = "text/plain"
 
     page = Page(request, pagename)
     tags = TagStore(page)
--- a/MoinMoin/action/sisterpages.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/action/sisterpages.py	Sat Jun 21 16:57:20 2008 +0200
@@ -32,23 +32,23 @@
     if request.if_modified_since == timestamp:
         if request.if_none_match:
             if request.if_none_match == etag:
-                request.response.status_code = 304
+                request.status_code = 304
         else:
-            request.response.status_code = 304
+            request.status_code = 304
     elif request.if_none_match == etag:
         if request.if_modified_since:
             if request.if_modified_since == timestamp:
-                request.response.status_code = 304
+                request.status_code = 304
         else:
-            request.response.status_code = 304
+            request.status_code = 304
     else:
         # generate an Expires header, using 1d cache lifetime of sisterpages list
         expires = time.time() + 24*3600
 
-        request.response.mime_type = 'text/plain'
-        request.response.expires = expires
-        request.response.last_modified = timestamp
-        request.response.headers.add("Etag", etag)
+        request.mime_type = 'text/plain'
+        request.expires = expires
+        request.last_modified = timestamp
+        request.headers.add("Etag", etag)
 
         # send the generated XML document
         baseurl = request.getBaseURL()
--- a/MoinMoin/action/sitemap.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/action/sitemap.py	Sat Jun 21 16:57:20 2008 +0200
@@ -64,7 +64,7 @@
     request.user.datetime_fmt = datetime_fmt
     base = request.getBaseURL()
 
-    request.response.mimetype ='text/xml'
+    request.mimetype ='text/xml'
 
     # we emit a piece of data so other side doesn't get bored:
     request.write("""<?xml version="1.0" encoding="UTF-8"?>\r\n""")
--- a/MoinMoin/action/titleindex.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/action/titleindex.py	Sat Jun 21 16:57:20 2008 +0200
@@ -21,7 +21,7 @@
         mimetype = form['mimetype'][0]
     else:
         mimetype = "text/plain"
-    request.response.mimetype = mimetype
+    request.mimetype = mimetype
 
     # Get list of user readable pages
     pages = request.rootpage.getPageList()
--- a/MoinMoin/auth/http.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/auth/http.py	Sat Jun 21 16:57:20 2008 +0200
@@ -35,7 +35,7 @@
         # for standalone, request authorization and verify it,
         # deny access if it isn't verified
         if isinstance(request, request_standalone.Request):
-            request.response.www_authenticate.set_basic(realm="MoinMoin")
+            request.www_authenticate.set_basic(realm="MoinMoin")
             
             auth = request.authorization
             if auth:
--- a/MoinMoin/session.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/session.py	Sat Jun 21 16:57:20 2008 +0200
@@ -328,7 +328,7 @@
         domain = request.cfg.cookie_domain or None
         path = request.cfg.cookie_path or None
         # Set cookie
-        request.response.set_cookie(self.cookie_name, cookie_string,
+        request.set_cookie(self.cookie_name, cookie_string,
                                     max_age=lifetime, expires=expires,
                                     path=path, domain=domain)
         # IMPORTANT: Prevent caching of current page and cookie
--- a/MoinMoin/stats/hitcounts.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/stats/hitcounts.py	Sat Jun 21 16:57:20 2008 +0200
@@ -252,8 +252,8 @@
         (request.cfg.chart_options['width'], request.cfg.chart_options['height']),
         image, days)
 
-    request.response.content_type = 'image/gif'
-    request.response.content_length = len(image.getvalue())
+    request.content_type = 'image/gif'
+    request.content_length = len(image.getvalue())
 
     # copy the image
     image.reset()
--- a/MoinMoin/stats/pagesize.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/stats/pagesize.py	Sat Jun 21 16:57:20 2008 +0200
@@ -113,8 +113,8 @@
         (request.cfg.chart_options['width'], request.cfg.chart_options['height']),
         image, labels)
 
-    request.response.content_type = 'image/gif'
-    request.response.content_length = len(image.getvalue())
+    request.content_type = 'image/gif'
+    request.content_length = len(image.getvalue())
 
     # copy the image
     image.reset()
--- a/MoinMoin/stats/useragents.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/stats/useragents.py	Sat Jun 21 16:57:20 2008 +0200
@@ -173,8 +173,8 @@
         (request.cfg.chart_options['width'], request.cfg.chart_options['height']),
         image, labels)
 
-    request.response.content_type = 'image/gif'
-    request.response.content_length = len(image.getvalue())
+    request.content_type = 'image/gif'
+    request.content_length = len(image.getvalue())
 
     # copy the image
     image.reset()
--- a/MoinMoin/xmlrpc/__init__.py	Thu Jun 19 18:23:02 2008 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Sat Jun 21 16:57:20 2008 +0200
@@ -166,8 +166,8 @@
                 # serialize it
                 response = xmlrpclib.dumps(response, methodresponse=1)
 
-        self.request.response.content_type = 'text/xml'
-        self.request.response.content_length = len(response)
+        self.request.content_type = 'text/xml'
+        self.request.content_length = len(response)
         self.request.write(response)
 
     def dispatch(self, method, params):