[ZDP] External Method (simple)

F.G. Hoekstra hoekstra@fsw.LeidenUniv.nl
Mon, 08 Mar 1999 14:13:28 +0100


A few basic FAQ (perhaps not F but at least A, is it too basic?). I assumed
passing a 'self' method explicitly to an External Method is not necessary,
at least it worked for me without. This is my first contribution to the ZDP
list, do you consider this a contribution of any value?

Rik Hoekstra


* How do I add a Folder in an external Method
    - Create an external Method in your <ZOPEdir>/External directory. If
      you want the folder created within the Folder you call it from,
      pass the method a default self-argument.
      The External method may look something like:

      def exmplMethod(self, id, title):
          self.manage_addFolder(name, title)

    - Add an external method in the zope management screen.

    - Call the external method from a DTMLdocument or DTMLMethod. If you
      called your External Method "extrnlMethod":

      <!--#call "extrnlMethod('id', 'title')" -->

    - If you want feed your method input from a form, call the
      DTMLdocument/method in your form ("<FORM ACTION="DTMLDocument"
      METHOD="POST">) and use the REQUEST['field'] as input, like:

      <!--#call "extrnlMethod(REQUEST['id'], REQUEST['title'])"-->

* How do I first add a Folder and add a Property or Document to it in an
External Method

    - Create an external Method in your <ZOPEdir>/External directory. If
      you want the folder created within the Folder you call it from,
      pass the method a default self-argument. Assuming the new Folder was
      created in the current folder, call with:

      newFolderObj = getattr(self, newFoldername)

      then assign the Document/property to it with:

      newFolderObj.manage_AddDocument(id, title, content)

      or

      newFolderObj._setProperty(id, value, type)