Python advice needed to survive check-code
jim.hague at acm.org
Wed Jan 11 04:25:20 CST 2012
Help! Advice needed by a Mercurial & Python non-guru.
I've got a patch for the Bugzilla extension lined up, fixing the omission of
http support for the XML-RPC Bugzilla interaction modes.
As part of that, I need modified xmlrpclib Transport and SafeTransport classes
that remember and return cookies, specifically the Bugzilla login cookie. So, I
need to add a cookie store, cookie sending and replace the request() method. I
could subclass both, but don't want to repeat the same code.
My solution so far is thus:
cookies = 
def send_cookies(self, connection):
# Add cookies to outbound headers.
def request(self, host, handler, request_body, verbose=0):
# Request that parses cookies and sends them in outbound headers.
class cookietransport(cookietransportrequest, xmlrpclib.Transport):
class cookiesafetransport(cookietransportrequest, xmlrpclib.SafeTransport):
The problem is that for this to work cookietransportrequest has to be an old-
style class to match xmlrpclib.(Safe|)Transport, or __init__s don't get called
properly. But then I fall foul of check-code.py, and I don't see a way to turn
off the check for just that class def, only the entire file, which seems
overkill. Alternatively, I can make it work with a new-style
cookietransportrequest by explicitly calling the Transport __init__s, but that
seems somehow a bit ugly.
I'm unsure how to proceed. Any suggestions?
Jim Hague - jim.hague at acm.org Never trust a computer you can't lift.
More information about the Mercurial-devel