Details

Applies to
1.6.3
Purpose
Allow CLI to use actions and correct URIs
Description
This patch may not consider too many other things, may break something else.

Patch

   1 --- request_cli.py	2008-05-10 11:33:38.000000000 +0800
   2 +++ request_cli.py.old	2008-05-10 01:03:13.000000000 +0800
   3 @@ -14,20 +14,18 @@
   4      """ specialized on command line interface and script requests """
   5  
   6      def __init__(self, url='CLI', pagename='', properties={}):
   7 -        from urlparse import urlparse
   8 -        url = urlparse(url)
   9          self.saved_cookie = ''
  10          self.path_info = '/' + pagename
  11 -        self.query_string = url.query
  12 +        self.query_string = ''
  13          self.remote_addr = '127.0.0.1'
  14          self.is_ssl = 0
  15          self.http_user_agent = 'CLI/Script'
  16 -        self.url = url.geturl()
  17 +        self.url = url
  18          self.request_method = 'GET'
  19          self.request_uri = '/' + pagename # TODO check if /pagename works as URI for CLI usage
  20 -        self.http_host = url.netloc
  21 +        self.http_host = 'localhost'
  22          self.http_referer = ''
  23 -        self.script_name = ''
  24 +        self.script_name = '.'
  25          self.if_modified_since = None
  26          self.if_none_match = None
  27          RequestBase.__init__(self, properties)
  28 @@ -70,13 +68,13 @@
  29  
  30      # Accessors --------------------------------------------------------
  31  
  32 -#    def getQualifiedURL(self, uri=None):
  33 -#        """ Return a full URL starting with schema and host
  34 -#        
  35 -#        TODO: does this create correct pages when you render wiki pages
  36 -#              within a cli request?!
  37 -#        """
  38 -#        return uri
  39 +    def getQualifiedURL(self, uri=None):
  40 +        """ Return a full URL starting with schema and host
  41 +        
  42 +        TODO: does this create correct pages when you render wiki pages
  43 +              within a cli request?!
  44 +        """
  45 +        return uri
  46  
  47      # Headers ----------------------------------------------------------
  48  
request_cli.py.patch

Discussion

I need to run sitemap action through CLI interface (I simply don't want to leave a record in my web server's access log), so I tried to use moin cli show. I found out:

  1. request_cli.py is fixed, so it's impossible to run action

  2. Generated URIs of page are incorrect, even you specify --wiki-url, same cause as above.

So I quickly made a change to request_cli.py, however, I don't have fully perspective of MoinMoin, this patch may break something. Even it doesn't, it may not be enough for all situations.

After patching, need to run with

moin --config-dir=/path/to/config/ --wiki-url="http://example.com/?action=sitemap&underlay=0" cli show

Plan


CategoryMoinMoinPatch

MoinMoin: MoinMoinPatch/RequestCli (last edited 2008-05-10 04:04:49 by YuJieLin)