changeset 1007:8cc609b746de

request.action now has the action for the current request, default 'show'
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 22 Jul 2006 15:49:40 +0200
parents 509ea9995c9d
children 43279823cf24
files MoinMoin/request/__init__.py docs/CHANGES
diffstat 2 files changed, 19 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/request/__init__.py	Sat Jul 22 14:45:58 2006 +0200
+++ b/MoinMoin/request/__init__.py	Sat Jul 22 15:49:40 2006 +0200
@@ -141,11 +141,13 @@
             #    # no extra path after script name
             #    rootname = u""
 
-            self.args = {}
-            self.form = {}
-
-            if not self.query_string.startswith('action=xmlrpc'):
+            if self.query_string.startswith('action=xmlrpc'):
+                self.args = {}
+                self.form = {}
+                self.action = 'xmlrpc'
+            else:
                 self.args = self.form = self.setup_args()
+                self.action = self.form.get('action', ['show'])[0]
 
             rootname = u''
             self.rootpage = Page(self, rootname, is_rootpage=1)
@@ -156,7 +158,7 @@
 
             self.user = self.get_user_from_form()
 
-            if not self.query_string.startswith('action=xmlrpc'):
+            if self.action != 'xmlrpc':
                 if not self.forbidden and self.isForbidden():
                     self.makeForbidden403()
                 if not self.forbidden and self.surge_protect():
@@ -181,7 +183,7 @@
         current_id = validuser and self.user.name or self.remote_addr
         if not validuser and current_id.startswith('127.'): # localnet
             return False
-        current_action = self.form.get('action', ['show'])[0]
+        current_action = self.action
 
         limits = self.cfg.surge_action_limits
         default_limit = self.cfg.surge_action_limits.get('default', (30, 60))
@@ -863,11 +865,12 @@
         forbidden = 0
         # we do not have a parsed query string here, so we can just do simple matching
         qs = self.query_string
+        action = self.action
         if ((qs != '' or self.request_method != 'GET') and
-            not 'action=rss_rc' in qs and
+            action != 'rss_rc' and
             # allow spiders to get attachments and do 'show'
-            not ('action=AttachFile' in qs and 'do=get' in qs) and
-            not 'action=show' in qs
+            not (action == 'AttachFile' and 'do=get' in qs) and
+            action != 'show'
             ):
             forbidden = self.isSpiderAgent
 
@@ -1028,22 +1031,19 @@
         self.html_formatter = Formatter(self)
         self.formatter = self.html_formatter
 
-        if self.query_string == 'action=xmlrpc':
+        action_name = self.action
+        if action_name == 'xmlrpc':
             from MoinMoin import xmlrpc
-            xmlrpc.xmlrpc(self)
-            return self.finish()
-
-        if self.query_string == 'action=xmlrpc2':
-            from MoinMoin import xmlrpc
-            xmlrpc.xmlrpc2(self)
+            if self.query_string == 'action=xmlrpc':
+                xmlrpc.xmlrpc(self)
+            elif self.query_string == 'action=xmlrpc2':
+                xmlrpc.xmlrpc2(self)
             return self.finish()
 
         # parse request data
         try:
             self.initTheme()
 
-            action_name = self.form.get('action', ['show'])[0]
-
             # The last component in path_info is the page name, if any
             path = self.getPathinfo()
             if path.startswith('/'):
--- a/docs/CHANGES	Sat Jul 22 14:45:58 2006 +0200
+++ b/docs/CHANGES	Sat Jul 22 15:49:40 2006 +0200
@@ -116,6 +116,7 @@
     * removed all _ magic in URLs and filenames
       TODO: write mig script for data_dir
       TODO: make blanks in interwiki pagelinks possible
+    * request.action now has the action requested, default: 'show'.
 
   New Features:
     * Removed "underscore in URL" == "blank in pagename magic" - it made more