view MoinMoin/support/ @ 4510:6180f7b85a45

Modernized theme: make nonexistent links gray also when the yare already visited
author Radomir Dopieralski <>
date Sat, 24 Jan 2009 21:49:44 +0100
parents c1c0d7f6f2b4
line wrap: on
line source
# taken from Amos' XML-RPC HowTo:

import xmlrpclib, httplib
from base64 import encodestring

class BasicAuthTransport(xmlrpclib.Transport):
    def __init__(self, username=None, password=None):
        self.username = username
        self.password = password
        self.verbose = 0

    def request(self, host, handler, request_body, **kw):
        # issue XML-RPC request
        h = httplib.HTTP(host)
        h.putrequest("POST", handler)

        # required by HTTP/1.1
        h.putheader("Host", host)

        # required by XML-RPC
        h.putheader("User-Agent", self.user_agent)
        h.putheader("Content-Type", "text/xml")
        h.putheader("Content-Length", str(len(request_body)))

        # basic auth
        if self.username is not None and self.password is not None:
            authhdr = "Basic %s" % encodestring("%s:%s" % (self.username, self.password)).replace("\012", "")
            h.putheader("Authorization", authhdr)

        if request_body:

        errcode, errmsg, headers = h.getreply()

        if errcode != 200:
            raise xmlrpclib.ProtocolError(
                host + handler,
                errcode, errmsg,

        return self.parse_response(h.getfile())