[ZDP] External Method (simple)

Martijn Faassen M.Faassen@vet.uu.nl
Mon, 08 Mar 1999 16:43:33 +0100


Hi there,

I'm trying to edit Rik Hoekstra's contributions for inclusion in the
main FAQ and I'm running into some questions I'd like some feedback on
from the list.

Here's the edited entry so far:

* How do I add a Folder in an External Method?

    If you want the folder created within the Folder you call it from,
    use 'self' as the first argument ('self' should be passed
    automatically, though sometimes there are subtle difficulties
    about which we should have more FAQs [FIXME]).

    This External Method adds a folder to 'self'::

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

    You can then call this External Method from a DTML Document or
    DTML Method. [FIXME: will this work with DTML Documents too? Isn't
    'self' the non-folderish Document in that case?] For instance::

        <!--#call "myAddFolder('some_id', 'some_title')" -->

I'd like some clarifications on the 'FIXME's.

Then there Rik's following suggestion:

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

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

Isn't it easier in this case to call the External Method directly? Of
course the #call way allows one to create a feedback form in DTML. I'd
like it if someone wrote up a clear set of FAQs on the ways to call
External Methods from forms, and such. I'm leaving this out of the FAQ
for now, but I think it'd be very useful; I imagine people struggle with
getting forms to work the right way (probably because we tend to assume
it's more difficult than it actually is with Zope :).

Regards,

Martijn