[Zope] one external method calling another; what possibilities?

knight knight@righteous.net
Fri, 6 Oct 2000 18:42:49 -0700 (PDT)


External methods are not extensions to any Zope classes. External methods
allow you to incorporate external functionality from Zope, as you already
know. You can define classes that are referenced in your functions though.

Keep in mind, that the external method that you created that gets called
is just a function. By default, self gets passed in, so be sure its in
your function definition. When calling _another_ function from your
external method, self does NOT get passed, since your external method does
not belong to a specific class instance... i.e. there's no container to
pass as self. So you have to pass self explicitly.

Example:

def myextmethod(self, somevar):
  something()
  morethings()

  myotherfunc(self, somevar):

def myotherfunc(self, somevar):
  print somevar

If this doesn't help, please clarify what exactly you are trying to do...

Knight
knight@phunc.com

On Fri, 6 Oct 2000, Fred Yankowski wrote:

> I'm using some example code that defines an External Method to process
> a form.  That External Method calls another utility function to log
> some data.  I'm not quite sure what choices I have for creating that
> utility function, so I created another External Method for it.  Both
> functions are in the same Python source file in the Extensions folder.
> 
> Anyway, the main external function calls the utility function like this:
> 
> 	self.function2(arg1=valuex, arg2=valuey)
> 
> I expected that function2 would have to be defined like this:
> 
> 	def function2(self, **kwargs)
> 
> but it turned out that that fails at runtime with a complaint about a
> mismatch between the number of arguments sent and expected (0 and 1,
> respectively).  The following does work:
> 
> 	def function2(**kwargs)
> 
> So, why isn't function2 called as a method function?
> 
> Was there some better way I could have implemented function2, rather
> than as an external method?
> 
> Where is reference documentation on External Methods?  I couldn't find
> anything other than a very cursory overview in one of the PDF'ed
> documents (I forget which).
> 
> -- 
> Fred Yankowski           fred@OntoSys.com      tel: +1.630.879.1312
> Principal Consultant     www.OntoSys.com       fax: +1.630.879.1370
> OntoSys, Inc             38W242 Deerpath Rd, Batavia, IL 60510, USA
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
> 
>