[Zope] How to I use aquisition in an external method?

Martijn Pieters mj@digicool.com
Fri, 21 Jan 2000 04:09:12 -0500


> -----Original Message-----
> From: Chris McDonough [mailto:chrism@digicool.com]
> 
> Dylan,
> 
> I usually pass "this()" in to an external method to get a handle on
> acquisition from an external method.
> 
> e.g.:
> 
> <dtml-call "emMyExternalMethod(this())">
> 
> def myExternalMethod(context):
>     if context.folder.attribute:
>         do something
>     else:
>         do something else
> 
> this() generally refers to the folder containing the dtml method.  in
> the external method, you can use acquisition through this object.
> 
> "Jay, Dylan" wrote:
> > 
> > I want to find out if a callable object exists from a 
> folder object using
> > acquisition. ie if I call folder.method() it will be 
> guaranteed to work.
> > 

If your external method signature has 'self' as the first parameter, the
current object (be it the Folder or DTML Document or some such), will be
passed in with that parameter.

So:

  def MyExternalAttribute(self)
    return self.acquired_folder.attribute

-- 
Martijn Pieters, Software Engineer 
| Digital Creations http://www.digicool.com 
| Creators of Zope      http://www.zope.org 
| mailto:mj@digicool.com       ICQ: 4532236
| PGP:
http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 
-------------------------------------------