[Zope] Recursively read and write folders during install

David Pratt fairwinds at eastlink.ca
Sun Mar 20 20:37:14 EST 2005


Thank you Dieter and others for responding.  I was looking at doing 
something with a class and os.path.walk to do something like this - if 
I could not find something already in use but put a hold on this to 
look at the DirectoryView idea more closely. I have only ever seen a 
DirectoryView used in skins such as;

from Products.CMFCore import DirectoryView
DirectoryView.registerDirectory('skins/my_scripts_and_templates', 
globals())

I like very much the idea of what you have suggested and hadn't really 
considered a DirectoryView in the site root before. I guess as long as 
you register the directory you can create a directory view pretty much 
anywhere - which is interesting and at the same time similar to 
products out there like LocalFS.  In my situation, the folder hierarchy 
and templates are responsible for giving the site its path structure.  
I also have generic templates in a skins folder with most scripts to 
deal with the normal things the site will have to do.  So it was 
important to keep the heirarchy of folders and templates in tact. I did 
not want to simply create a folder in skins that would get any of its 
templates through acquisition.  DirectoryView is recursive and gets 
everything under it just fine. On top of it is the real benefit that to 
make any future changes to this base material will only ever need do be 
done in the product.

The only issue real issue for me is that there are some properties that 
I need to maintain on the folders as well for certain types of 
functionality.  So this is where I may be hooped.  DirectoryView 
doesn't appear to allow any properties on the folder other than its 
path.  I guess the question is there a way to add to the properties of 
a DirectoryView folder?? from the filesystem.  I have found a reference 
to a FSPropertyObject but have yet to find any examples of using it for 
something like this.  I have string, boolean, int, lines and text 
properties that are folder specific.

Regards,
David

On Saturday, March 19, 2005, at 03:03 PM, Dieter Maurer wrote:

> David Pratt wrote at 2005-3-18 22:43 -0400:
>> I am creating a product on the filesystem.  Outside of the skins
>> that contain generic scripts and templates, I am organizing a series 
>> of
>> folders and their contents in the same hierarchy that I to want it
>> appear in my CMF site.
>
> You use "os.listdir" and "os.path.isdir" on the filesystem side
> and "manage_addFolder" for directories and appropriate
> other constructors for files on the ZODB side.
>
> Or you use a "DirectoryView" (in case, your file hiearchy
> does not contain content but templates and scripts).
>
> -- 
> Dieter
>


More information about the Zope mailing list