[Soap-Python] Why do I get Exception: __main__.Tiny.doit overwrites __main__.Tiny.doit ?
J.Fine
j.fine at open.ac.uk
Fri Mar 25 18:32:59 CET 2011
> From: Chris Austin
> Sent: 25 March 2011 17:03
> On Fri, Mar 25, 2011 at 10:47 AM, J.Fine <j.fine at open.ac.uk> wrote:
> > Hi
> >
> > I was surprised to get an exception from this piece of code.
> >
> > $ cat examples/method_names.py
> > from soaplib.service import rpc, DefinitionBase from
> > soaplib.serializers.primitive import String from
> soaplib.wsgi import
> > Application
> >
> > def doit(self):
> > return 'this is a string'
> >
> >
> > class Tiny(DefinitionBase):
> >
> > # Unpack the rpc decorator.
> > wibble = rpc(_returns=String)(doit)
> > wobble = rpc(_returns=String)(doit)
> >
> > application = Application([Tiny], 'namespace')
> >
> >
> > And I was surprised by the exception I got. How does
> soaplib know that my function was called doit? And should it know?
> >
>
> This is how soaplib works. Soaplib introspects the methods
> decorated with @soap, @rpc or, @document. It crams these
> web-methods into a public_methods dictionary.
Yes, but this does not explain why 'doit' is used (twice) as the key in the public_methods dictionary, rather than 'wibble' and 'wobble'. Reading the code for Tiny I'd be expecting to get two web-methods (wibble and wobble) and not doit and an exception.
--
Jonathan
--
The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in England & Wales and a charity registered in Scotland (SC 038302).
More information about the Soap
mailing list