[Zope] ZCGI Documentation
Fri, 28 Mar 2003 07:53:11 -0500
Thanks JC, this is one email I'm going to tuck away as a reference. I knew
there had to be a way but my confussion and not finding the right reference
material/web source leads me in the wrong directions sometimes. Thanks
From: firstname.lastname@example.org [mailto:email@example.com]On Behalf Of J
Sent: Thursday, March 27, 2003 5:57 PM
Subject: Re: [Zope] ZCGI Documentation
>I have a cgi script to uploading files to a file system I am trying to
>I have posted questions about localfs and extfile that seem to fit my needs
>but I have not found a solution that a user can run the product from ex.
>index_html. I can only run the product through the management interface. I
>am trying to avoid setting up user accounts.
You don't need CGI for this (and in fact, I'm not even sure how it would
fit in: in such a configuration Zope doesn't run CGI, is is run via CGI.)
One of the rules of Zope is that whatever you can do from the management
interface you can do anywhere. There really is no magic involved. Now,
products aren't going to give you clever interfaces for inclusion with
your code, because they can't even begin to know what you have in mind.
What you can do, however, is to treat their management interfaces as a
template to make your own interface. Say you want to allow someone to
create a File from wherever. You like index_html, so we'll use that.
(I'm using File rather than ExtFile for this example so that those
playing along at home aren't left out; the principle is exactly the same.)
Here's a crash course on how to do that:
How does File add a File instance to some folder? Watch the URLs in the
ZMI when you do that from the pull-down. It calls
on some Folder(ish) object. This is defined in the __init__.py in
As you can see, it has the various fields in an HTML form that are
necessary to create a File. What is the action of the form? Take a look
at the source. It is
relative to the current Folderish object. So, calling that on some
folder with a request containing the parameters like the form constructs
will create a File and add it to that folder.
So now you want to create your own interface for adding Files. Copy the
form code out of the File's add page, and stick it in your own page
(index_html), changing the formatting if you like. Setting the action to
manage_addFile is the most important part. You would have to do the same
thing for the edit pages, if you want to be able to edit.
There are some problems here, like 'manage_addFile' redirects to
'manage_main'. If you don't like that, you can either create a script
that calls 'manage_addFile(REQUEST)' and returns/redirects where you
want, or you can write your own file-add function that calls the class
constructor to make the instance and adds it to the folder with
'_setObject' in a similar manner to the original code. Alternatively,
you can create your own product that subclasses File and change the
behaviour of whatever functions you like.
Zope maillist - Zope@zope.org
** No cross posts or HTML encoding! **
(Related lists -