I've tried calling Zope 2.10.9's ZPublisher.Client.call
with the method
argument to set the HTTP method (GET
, POST
, etc.), but it's not working as expected: It always sends a POST request. If I don't supply the method
argument it always sends a GET request.
Application code:
Client.call(
'http://...',
username = 'jdoe',
password = 'mypw',
method = 'GET')
I've traced it a bit in Client.py:
def call(url,username=None, password=None, **kw):
return apply(Function(url,username=username, password=password), (), kw)
OK, so kw = { 'method': 'GET' }
. As far as I can tell this translates to
Function.__init__(
'http://...',
username = 'jdoe',
password = 'mypw'
).__call__(
method = 'GET')
Function.__init__
expects method
as part of its arguments but it's not passed there:
def __init__(self,url,
arguments=(),method=None,username=None,password=None,
timeout=None,
**headers):
...
if method is not None: self.method=method
Function.__call__
expects method
to be set already:
def __call__(self,*args,**kw):
method=self.method
Should call
's signature and the apply
call be modified to fit __init__
, or am I misunderstanding something? If it's really an error, here's a proposed patch (Works For Me™):
--- Client.py.orig
+++ Client.py
@@ -271,9 +271,9 @@
return f
-def call(url,username=None, password=None, **kw):
+def call(url, arguments=(), method=None, username=None, password=None, timeout=None, **kw):
- return apply(Function(url,username=username, password=password), (), kw)
+ return apply(Function(url, arguments=arguments, method=method, username=username, password=password, timeout=timeout), (), kw)
##############################################################################
# Implementation details below here