Description

The environment variable http_proxy is ignored, ater starteing wikiserver.py and trying to sync.

Steps to reproduce

  1. export http_proxy="http://127.0.0.1:3128" # Or whatever Web Proxy is needed

  2. ./wikiserver.py
  3. Run action=SyncPages

Example

You will get the Message "The wiki is currently not reachable"

Component selection

Details

Workaround

here is my patch:

--- moin-1.7.2.org/MoinMoin/wikisync.py 2008-03-22 23:02:46.000000000 +0000
+++ moin-1.7.2/MoinMoin/wikisync.py     2008-10-08 08:07:40.831318400 +0000
@@ -9,6 +9,9 @@
 import os
 import socket
 import xmlrpclib
+import httplib
+import urlparse
+

 from MoinMoin import wikiutil
 from MoinMoin.util import lock, pickle
@@ -17,6 +20,9 @@
 from MoinMoin.packages import unpackLine, packLine
 from MoinMoin.support.multicall import MultiCall

+from MoinMoin import log
+logging = log.getLogger(__name__)
+

 MIMETYPE_MOIN = "text/wiki"
 # sync directions
@@ -156,6 +162,17 @@
         """ Returns a list of SyncPage instances. """
         return NotImplemented

+class ProxiedTransport(xmlrpclib.Transport):
+    def set_proxy(self, proxy):
+        self.proxy = proxy
+    def make_connection(self, host):
+        self.realhost = host
+       h = httplib.HTTP(self.proxy)
+       return h
+    def send_request(self, connection, handler, request_body):
+        connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
+    def send_host(self, connection, host):
+        connection.putheader('Host', self.realhost)

 class MoinRemoteWiki(RemoteWiki):
     """ Used for MoinMoin wikis reachable via XMLRPC. """
@@ -166,6 +183,7 @@
         self.verbose = verbose
         _ = self.request.getText

+        self.verbose=True
         wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_interwiki(self.request, interwikiname, '')
         self.wiki_url = wikiutil.mapURL(self.request, wikiurl)
         self.valid = not wikitag_bad
@@ -205,8 +223,18 @@
         else:
             self.iwid_full = packLine([remote_iwid, interwikiname])

+
     def createConnection(self):
-        return xmlrpclib.ServerProxy(self.xmlrpc_url, allow_none=True, verbose=self.verbose)
+        proxy=os.getenv("http_proxy") # exp: proxy="http://127.0.0.1:3128"
+        logging.debug("proxy=<%s>" % proxy)
+        if ( proxy != None ):
+            p = ProxiedTransport()
+            proxy=urlparse.urlparse(proxy)[1] # exp: proxy="127.0.0.1:3128"
+            logging.debug("proxy=<%s>" % proxy)
+            p.set_proxy(proxy)
+            return xmlrpclib.ServerProxy(self.xmlrpc_url, transport=p, allow_none=True, verbose=self.verbose)
+        else:
+            return xmlrpclib.ServerProxy(self.xmlrpc_url, allow_none=True, verbose=self.verbose)

     # Public methods
     def get_diff_pre(self, pagename, from_rev, to_rev, n_name=None):

Discussion

Isn't this rather a feature request than a bug?

Plan


CategoryMoinMoinBug

MoinMoin: MoinMoinBugs/WikiSyncIgnoresHttp_proxy (last edited 2008-10-08 10:04:13 by ThomasWaldmann)