[Zope] "real file" product
Jud Dagnall
jdagnall@sgi.com
Tue, 26 Mar 2002 18:00:09 -0800
> Now I have to create image file objects dynamically from my
application
> which has kind of "Upload image" mechanism. I would like to have an
> easy to use create_externel_image method but the documentation how to
> do that is quite sparse for all three products.
>
> Some examples, how to do that would be helpful.
I used the ExtFile product so that I could save some metadata about each
file in Zope (although I didn't end up adding the extra metadata).
AFAIK Local File System doesn't allow one to do that. However, be
careful with the storage directory method you use if you choose ExtFile.
I set ExtFile to mirror the Zope directory structure. However, later on
in the development process, I wanted to change my Zope folder structure.
This caused problems: Zope kept looking for the objects where they had
been created even though I moved the disk files into the new directory.
I assume ExtFile stores the directory path at creation time, and it
should only be a matter of identifying this attribute and then modifying
it programmatically. However, since I was still using test files I just
deleted the orphans in Zope and on disk.
I used the ExtFile add file page as a basic template (since I wanted to
have my own interface).
Here's the code. It's really primitive, but got the job done for me:
My HTLM add_file_form (minus formatting):
===Begin======================
<form action="add_file_action" method="post"
enctype="multipart/form-data" name="form">
<br />Title:<br /><input type="text" name="title" size="40">
<br />Notes:<br /><input type="text" name="descr" size="40">
<br /><input type="file" name="file" size="25" value="">
<br /><input type="submit" value=" Add ">
</form>
===End======================
my dtml method add_file_action (minus error checking).
I wanted to store the new items in a subfolder called downloads.
===Begin======================
<dtml-with REQUEST>
<dtml-let id="''">
<dtml-var
expr="downloads.manage_addProduct['ExtFile'].manage_addExtFile(
id, title, descr, file)">
</dtml-let>
</dtml-with>
<dtml-var standard_html_header>
Success!
<dtml-var standard_html_footer>
===End======================
I was playing around with some code to add and set unique properties at
creation time. I've got that code is somewhere, if you're interested,
although the project eventually got dropped.
HTH
Jud
--
Jud Dagnall
SGI Electronic Services
jdagnall@sgi.com
650.933.7256