changeset 5177:84c05e657b47

http_redirect: use code=<int> instead of status=<str> to make api in 1.8 same as in 1.9 / werkzeug
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 03 Oct 2009 22:37:06 +0200
parents ece8d64f8a57
children d60888cbfb22 76fac2e548a7
files MoinMoin/Page.py MoinMoin/action/RenamePage.py MoinMoin/request/__init__.py MoinMoin/request/request_cli.py MoinMoin/request/request_twisted.py
diffstat 5 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Fri Oct 02 23:21:52 2009 +0200
+++ b/MoinMoin/Page.py	Sat Oct 03 22:37:06 2009 +0200
@@ -1033,7 +1033,7 @@
             redirect_url = Page(request, pagename).url(request,
                                                        querystr={'action': 'show', 'redirect': self.page_name, },
                                                        anchor=anchor)
-            request.http_redirect(redirect_url, status='301')
+            request.http_redirect(redirect_url, code=301)
             return
 
         # if necessary, load the formatter
--- a/MoinMoin/action/RenamePage.py	Fri Oct 02 23:21:52 2009 +0200
+++ b/MoinMoin/action/RenamePage.py	Sat Oct 03 22:37:06 2009 +0200
@@ -73,7 +73,7 @@
     def do_action_finish(self, success):
         if success:
             url = Page(self.request, self.newpagename).url(self.request)
-            self.request.http_redirect(url, status='301')
+            self.request.http_redirect(url, code=301)
         else:
             self.render_msg(self.make_form(), "dialog")
 
--- a/MoinMoin/request/__init__.py	Fri Oct 02 23:21:52 2009 +0200
+++ b/MoinMoin/request/__init__.py	Sat Oct 03 22:37:06 2009 +0200
@@ -1189,7 +1189,7 @@
             pg = Page(self, pname)
             if pg.exists():
                 url = pg.url(self)
-                self.http_redirect(url, status='301')
+                self.http_redirect(url, code=301)
                 return True
         return False
 
@@ -1332,16 +1332,16 @@
 
         return self.finish()
 
-    def http_redirect(self, url, status='302'):
+    def http_redirect(self, url, code=302):
         """ Redirect to a fully qualified, or server-rooted URL
 
         @param url: relative or absolute url, ascii using url encoding.
         """
         url = self.getQualifiedURL(url)
         header = {
-            "301": "Status: 301 Moved Permanently",
-            "302": "Status: 302 Found",
-        }[status]
+            301: "Status: 301 Moved Permanently",
+            302: "Status: 302 Found",
+        }[code]
         self.emit_http_headers([header, "Location: %s" % url])
 
     def emit_http_headers(self, more_headers=[], testing=False):
--- a/MoinMoin/request/request_cli.py	Fri Oct 02 23:21:52 2009 +0200
+++ b/MoinMoin/request/request_cli.py	Sat Oct 03 22:37:06 2009 +0200
@@ -94,7 +94,7 @@
         """ private method to send out preprocessed list of HTTP headers """
         pass
 
-    def http_redirect(self, url):
+    def http_redirect(self, url, code=302):
         """ Redirect to a fully qualified, or server-rooted URL
 
         TODO: Does this work for rendering redirect pages?
--- a/MoinMoin/request/request_twisted.py	Fri Oct 02 23:21:52 2009 +0200
+++ b/MoinMoin/request/request_twisted.py	Sat Oct 03 22:37:06 2009 +0200
@@ -129,10 +129,10 @@
             else:
                 self.twistd.setHeader(key, value)
 
-    def http_redirect(self, url, status='302'):
+    def http_redirect(self, url, code=302):
         """ Redirect to a fully qualified, or server-rooted URL
 
-        TODO: use status '301' or '302' to generate correct header
+        TODO: use code 301 or 302 to generate correct header
 
         @param url: relative or absolute url, ascii using url encoding.
         """