[Zope] Upload Zip files

Dieter Maurer dieter at handshake.de
Sat Dec 20 05:38:02 EST 2003


Brian Sullivan wrote at 2003-12-16 11:21 -0500:
>> ... ZipFolder use programmatically ...
> [DM] ... look at the ZMI source ...

>I must be missing some fundamental bit of information here -- I have
>DocFinder installed and have looked at the ZMI interfaces and the
>information provided by DocFinder but still can't figure out what I
>have to do.
>
>I am still looking for clues.
>
>Is there anyone out there that has used the ZipFolder product other
>than via the ZMI?

I did not see a response on the mailing list.
You may need to look yourself into your problem...

I can help only with general (quite abstract) advice:

  When you use the ZMI, a form works together with an action.
  The form collects the data necessary for the action.
  When the form is submitted, the action is called with
  the collected data. The action does the required operation.

  When you want to do the operation from your own code (a script
  or a form of yourself), you need to know the action
  and the required arguments.

  Usually, you learn about the action from the "form" elements
  "action" attribute. Often, part of the action is
  coded in ":method" or ":action" form control elements.
  The "input" elements inside the "form" element
  provide the parameters for the action call.

Example: File edit:

  The form's source is "OFS/dtml/fileEdit.dtml". It looks like

    ...
    <form action="<dtml-var URL1>" method="post" enctype="multipart/form-data">
      ...
      <input type="text" name="title" ...>
      ...
      <input type="text" name="content_type:required" ...>
      ...
      <input type="text" name="precondition" ...>
      ...
      <input class="form-element" type="submit" name="manage_edit:method" value="Save Changes">
      ...
      <input type="file" name="file" size="25" />
      ...
      <input class="form-element" type="submit" name="manage_upload:method" value="Upload">
      ...
    </form>

  This is an example where the action is not specified by the form's
  "action" attribute but by the ":method" in one of
  "input" elements.

  The form is submitted by either pressing the button "Save Changes"
  or "Upload". In the first case, the action is "manage_edit"
  in the second "manage_upload".

  The form collects data with names "title", "content_type", "precondition",
  "file" ... These data items are available for the actions.


  "DocFinder" tells you the signature (its arguments) of the actions:

    manage_edit(self, title, content_type, precondition='', filedata=None, REQUEST=None)

    manage_upload(self, file='', REQUEST=None)


  Form info and action signature together give you quite a good
  insight how to use the actions in your own software...

  In the example: you can use "fileObject.manage_upload(someFile)"
  to change "fileObject"'s content to "someFile"
  and "fileObject.manage_edit(title, content_type, precondition)"
  to change its "meta data".


A similar analysis for ZipFolder is left to you as an exercise
(I cannot help you with this, as I do not have ZipFolder" installed;
but it should not be difficult...)
  

-- 
Dieter



More information about the Zope mailing list