[Zope] Passing Parameters to External Methods

Paul Winkler pw_lists at slinkp.com
Wed Nov 16 12:31:08 EST 2005


On Wed, Nov 16, 2005 at 11:26:10AM -0600, J Cameron Cooper wrote:
> Asad Habib wrote:
> >Hi Cameron. You are right but the self parameter is implicitly passed.
> 
> It is implicitly passed, but must be explicitly defined::
> 
>  def createHtmlToPdf(self, in_htmlFile, in_domain, in_pdfFile):
>     return html2pdf(in_htmlFile, in_domain, in_pdfFile)
> 
> When you say::
> 
>    context.createHtmlToPdf(in_htmlFile, in_domain, in_pdfFile)
> 
> Python ends up calling this method/function something like::
> 
>    createHtmlToPdf(context, in_htmlFile, in_domain, in_pdfFile)
> 
> Your message signature must agree.

No, it's optional.  If you don't inlude "self" in the signature,
it's not passed.  You can see this in the source of ExternalMethod.py:

                if ((self._v_func_code.co_argcount-
                     len(self._v_func_defaults or ()) - 1 == len(args))
                    and self._v_func_code.co_varnames[0]=='self'):
                    return f(self.aq_parent.this(), *args, **kw)


I think the problem lies elsewhere. Traceback?

-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope mailing list