[Zope] Re: ref another file while adding file in ZMI

Patrick Price jprice22@wvu.edu
Mon, 19 Aug 2002 19:12:26 -0400


Tim Hicks wrote:
>>Rather than have to upload a file while adding a file object using ZMI,
>>how can I refer to another existing file in the object tree?
>>
>>I tried putting "/root/refs/quotes/file1" in the File box but the file
>>that was added had a mime type of application/octet-stream so I had
>>to set the mime type to text/html which is what the original object was. 
 >> Why didn't it pick up on the fact that file1 is text/html itself?
>>
>>I could copy the file but am trying to learn...
> 
> > You're trying to get a new object into the ZODB that is a copy of one that
> is already stored?  Why don't you want to use the copy/paste procedure,
> that's what it's there for?
> 
> tim
> 

I guess that what I observed was that even though the add file method 
uses the file extension (?) to determine the file type, if this same 
method is used to refer to an already existing file object within Zope, 
it won't do this.  I am guessing that the file extension attribute (if 
that's what the file add method is using to determine file type and not 
scanning for magic numbers in the file) is lost once the file is inside 
the ZODB, and the method for adding file objects external to Zope wasn't 
written with internal objects in mind.

It would make sense from an OO viewpoint (and from my limited Python/OO 
knowledge) if a method dealing with objects could handle both internal 
and external file objects in a consistent manner, but it's probably not 
necessary in this case as there are other facilities for copying files.

I was just curious.  Thanks for the reply regardless.

-Patrick
PS: My quoted text herein slightly edited to make more sense