[Zope] Passing Parameters to External Methods

J Cameron Cooper zope-l at jcameroncooper.com
Wed Nov 16 12:39:42 EST 2005


Paul Winkler wrote:
> 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?

I thought I'd seen that work before, but didn't want to dip into asides.

Oh well. There goes my guess.

		--jcc
-- 
"Building Websites with Plone"
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com


More information about the Zope mailing list