There are many circumstances where instance methods make sense. For example, a common use case that I have is to use domain-specific descendants of DefinitionBase as a mix-in with business objects. It is much simpler in this case to access the instance attributes.
Personally, I don't see how forcing these methods to be static or class based would improve or simplify things. What do you have in mind? Do you think there could be a cleaner way do it while maintaining a simple soap API? On Fri, Mar 25, 2011 at 10:22 AM, J.Fine <[email protected]> wrote: > Thanks, Chris, for your answer. However, it doesn't tell me why make it > instance rather than static. > > Are there any circumstances in which it would be sensible for say_hello or > some similar method to use the self argument? > > > Jonathan > >> -----Original Message----- >> From: Chris Austin [mailto:[email protected]] >> Sent: 25 March 2011 15:15 >> To: J.Fine >> Cc: [email protected] >> Subject: Re: [Soap-Python] Why the 'self' parameter in soap >> decorated methods? >> >> Hi Jonathan, >> >> Self is in the method signature for say_hello because it is >> an instance method of HelloWorldService. The soap decorator >> does not coerce the say_hello method into a static or class >> method. Nor does the other web-method decorators (@rpc & @document). >> >> Hope this helps. >> >> On Fri, Mar 25, 2011 at 7:23 AM, J.Fine <[email protected]> wrote: >> > Hi >> > >> > On the page >> > http://soaplib.github.com/soaplib/2_0/pages/helloworld.html I read >> > >> > class HelloWorldService(DefinitionBase): >> > @soap(String,Integer,_returns=Array(String)) >> > def say_hello(self,name,times): >> > results = [] >> > for i in range(0,times): >> > results.append('Hello, %s'%name) >> > return results >> > >> > >> > What's the purpose of the 'self' in the say_hello method. >> Are there any examples of it being used? >> > >> > (I should add that I'm an experienced Python programmer, >> and know the >> > purpose of self, and for that matter the staticmethod decorator.) >> > >> > Best regards >> > >> > >> > 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
