[Zope] including arbitrary files in zope products

Johan Carlsson johanc at easypublisher.com
Fri Sep 3 02:55:55 EDT 2004


Raja Subramanian wrote:

> Hi,
>     
> I am facing a basic problem with Zope that I'm unable to solve.
> 
> I want to embed a java applet (jar) in my zope product.  The
> jar file lives as "<Product Basedir>/www/foo.jar" on the filesystem.
> I want to make this available as "<Product Instance Dir>/foo.jar"
> inside zope.
> 
> To include ZPT files, I'm able to do -
> 
>     from Products.PageTemplates.PageTemplateFile import PageTemplateFile
>     ...
>     class Foo(Folder):
>         ...
>         index_html = PageTemplateFile('zpt/index_html', globals())
> 
> and make zpt files available inside zope.  How can I do the same for
> arbitrary files such as java archives and others?
> 
> I don't know how to use the "File" object for this purpose.  Can
> someone please help?

For Images you can use

from Globals import ImageFile
file=ImageFile('www/image.gif', globals())

I guess you can use the FS* object from CMF Core to
add other types of files, but I haven't tried it my self.

Of course the CMF also includes DirectoryView and there is a
standalone version of CMFs external file management that's
called FileSystemSite (I think?)
This is a solution that import whole directories at a time.

You could also write you own custom version of ImageFile,
the code (in App/ImageFile.py) isn't specialy complex.

Regards,
Johan Carlsson

-- 
Johan Carlsson          Tel: + 46 8 31 24 94
Colliberty              Mob: + 46 70 558 25 24
Torsgatan 72            Email: johanc at easypublisher.com
SE-113 37 STOCKHOLM


More information about the Zope mailing list