[Zope] How on Earth do you mix literals and variables in Zope?

Will Partridge Will Partridge <will@vonrex.com>
Tue, 9 Oct 2001 23:19:36 -0700


I've got a problem which is driving me insane.  It's  the same type of
problem I always run into with Zope -- the mixing of literals and
variables.

Here's what I'm trying to do:

I have a form which allows users to type in documents and then select
the folder to which their document will be added.  "folderName",
"documentID", "documentTitle", and "documentContent" are all passed
from this form.  "library" and "documents" are existing folder names,
that is, static paths.

On the processing page, I first tried:

<dtml-with "library.documents.folderName">
  <dtml-call "manage_addDTMLDocument(documentID, documentTitle, documentContent)">
</dtml-with>

That didn't work.  It gives an error saying there is no object
"folderName".  Fine, I wasn't expecting it to be that easy anyway
(though it would have been nice).

Then I tried:  

<dtml-with "library.documents.REQUEST['folderName']">
  <dtml-call "manage_addDTMLDocument(documentID, documentTitle, documentContent)">
</dtml-with>

This just puts the new document in the "documents" folder, not in its
chosen sub-folder.  It's like it just ignores the
REQUEST['folderName'], even though I can use invoke the same variable
elsewhere on the page and it works just fine.

Then, I tried nested dtml-with statments:

<dtml-with "library.documents">
  <dtml-with folderName>
    <dtml-call "manage_addDTMLDocument(documentID, documentTitle, documentContent)">
  </dtml-with>
</dtml-with>

And...

<dtml-with "library.documents">
  <dtml-with "REQUEST['folderName']">
    <dtml-call "manage_addDTMLDocument(documentID, documentTitle, documentContent)">
  </dtml-with>
</dtml-with>

Same result as before.  I can create documents in the last named
literal folder, but I can not create anything in the folder named from
the form.

Note that if I name the target folder explicitly, like:

<dtml-with "library.documents">
  <dtml-with "personnel">
    <dtml-call "manage_addDTMLDocument(documentID, documentTitle, documentContent)">
  </dtml-with>
</dtml-with>

It will indeed create a new document in the named folder,
"library/documents/personnel".  But this doesn't help me.  I need to
be able to create documents in the folder named in the form.

Can anybody help me?  And more importantly, can anyone tell what basic
fact it is I'm missing about how to use variables in Zope?  I tell
you, I waste more time screwing around with stuff like this.

Will Partridge
will@vonrex.com