[Zope] Building a site tree with the ZCatalog

Nico Grubert nicogrubert at gmail.com
Tue Oct 21 10:27:21 EDT 2008


Hi there

I use Zope 2.10.5 and I want to create a site tree using the ZCatalog 
instead of iterating recursive trough the entire object tree.

I have the following site structure (all things are folders):

- about
--- company
--- staff
----- homepages
------- phelps
--- phonebook
--- jobs
- research
--- ocean
----- atlantic
----- pacific
--- lake
--- river

My ZCatalog contains these entries:
- /research
- /research/ocean
- /research/ocean/pacific
- /research/ocean/atlantic
- /research/lake
- /research/river
- /about
- /about/company
- /about/staff
- /about/staff/homepages
- /about/staff/homepages/phelps
- /about/staff/phonebook
- /about/jobs
- /about

What I need is a list of these entries ordered according to the site 
structure. I would like to get this list:
  ['/about',
   '/about/company',
   '/about/staff',
   '/about/staff/homepages',
   '/about/staff/homepages/phelps',
   '/about/phonebook',
   '/about/jobs',
   '/research',
   '/research/ocean',
   '/research/ocean/atlantic',
   '/research/ocean/pacific',
   '/research/lake',
   '/research/river'
  ]

My Zcatalog is configured as follows:
Indexes:
  - path
  - position
  - title
  - id
Metadata:
  - physical_path
  - title
  - id

The index 'position' contains the a folder's position in it's parent folder.
In my example the folder "phonebook" contains "3" for position because 
it is in the 3rd position inside it's parent folder ("about").

Is it possible to build an ordered site tree with the ZCatalog only and 
if so, any ideas how I can do that?

Regards
Nico


More information about the Zope mailing list