[Zope-dev] XML-RPC External Method bug

Casey Duncan casey@zope.com
Wed, 8 Jan 2003 10:09:44 -0500


You should file a collector issue re this and give a specific set of step=
s to=20
exercise the bug. I corrected a seemingly similar bug recently. I assume =
you=20
have tried this on the 2.6.1 beta? I don't think anything changed between=
=20
2.6.0 and 2.6.1 in this regard but you never know. I do know I changed th=
ings=20
in there between 2.5.1 and 2.6.0.

-Casey

On Tuesday 07 January 2003 10:01 am, Nathan 'Nato' Uno wrote:
> Greetings!
>=20
> I've been working with some of my coworkers tracking a problem very
> similar to the one described in this thread:
> =09http://lists.zope.org/pipermail/zope-dev/2002-November/017922.html
>=20
> which is also outlined here:
> =09http://zope.nipltd.com/public/lists/zope-archive.nsf/ByKey/B9323F6D6=
66D3D5C
>=20
> and I've found out some things which may be helpful in finding a better
> long-term solution.
>=20
> There appears to be a problem with the way that External Methods are
> inspected when called via XML-RPC.  Specifically, mapply() doesn't know
> what arguments the external method is expecting, apparently because the
> 'func_defaults' attribute of the object doesn't seem to be set
> properly.  Interestingly enough, if apply() is called then the external
> method is fully inspected (presumably because it's actually invoked),
> after which the external method call works properly via XML-RPC.
>=20
> Practically this means that when I invoke an external method via XML-RP=
C
> and pass the correct arguments, mapply() doesn't know what arguments th=
e
> method is expecting, assumes (in essence) that it expects 0, and return=
s
> 'too many arguments' (where 1 > 0).  However, if I invoke the external
> method with *no* arguments, mapply() assumes that everything is good an=
d
> invokes apply(), which throws a TypeError (function expects at least 1
> argument, 0 given).  If I then invoke the method *again* with the prope=
r
> arguments (i.e. I use exactly the same call I made the first time), the=
n
> the object inspected by mapply() has the 'func_defaults' attribute
> correctly set and the method works properly.
>=20
> I've spent the better part of two days sprinkling LOG() calls throughou=
t
> ZPublisher, so I can give some more detailed information if anyone's
> really interested.
>=20
> In the meantime, I temporarily hacked my local copy of mapply() to
> invoke apply(object, '') for every call, forcing the method to be
> properly inspected/cached/whatever, then caught the TypeError and moved
> on to the rest of mapply.  This worked for me, causing all of my XML-RP=
C
> calls to function properly, but concerned me because it opened the
> possibility of apply(object, '') being called successfully twice for an
> object that takes no arguments.
>=20
> So I backed that out and hacked by local copy of publish() instead,
> calling apply(object, '') for any object whose path matches my external
> methods.  This should work for us without any unintended side effects,
> but I'd obviously like to be involved with a long-term solution that
> would benefit the whole community.
>=20
> Please let me know if there's any more information I can give or
> anything else I can contribute.  I'd be glad to do more legwork, but I
> got bogged down last night trying to unravel the inspection/creation of
> external method objects, and can't really proceed effectively without
> some pointers on how that stuff works and where to poke around.
>=20
> Thanks very much,
>=20
> Nathan 'Nato' Uno
> Hostway Corporation
> Nathan.Uno@hostway.com
>=20
>=20
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -=20
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
>=20