On Fri, Mar 25, 2011 at 10:47 AM, J.Fine <[email protected]> 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.  Also, it uses the meta-data attached to
the methods via the decorators to generate  XML Schemata and the WSDL.
 The same process creates the bindings that allow a service to pass a
soap request to correct web-method and return a soap response.

> BTW, Tiny has attributes wibble and wobble (which I do expect).  I was 
> expecting my SOAP service to have wibble and wobble methods, but perhaps it 
> has a doit.
>

You are correct, it has doit().

If you need to override your methods you could try something like this:

class Tiny(DefinitionBase):
    def do_it(self):
        return "this is a string"

    @rpc(_returns=String)
    def wibble(self):
        return self.do_it()

    @rpc(_returns=String)
    def wobble(self):
        return self.do_it()


Your use case certainly is logical and one that I would like soaplib
to support in the near-future. I'll add it to the wish list for a
future release.

Cheers

Chris

>
> 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).
>
> _______________________________________________
> Soap mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/soap
>
_______________________________________________
Soap mailing list
[email protected]
http://mail.python.org/mailman/listinfo/soap

Reply via email to