Well, the recursive-descent parser works really well - the following is
the first working prototype:

> class Root(controllers.Root):
>       def _descend(self, base, root):
>               for atom in root.Children:
>                       if hasattr(base, atom.Name.replace('-', '_')):
>                               raise Exception, "Object by the name " + 
> atom.Name.replace('-', '_') + " already exists!"
>                               continue
>                       if isinstance(atom, model.Page):
>                               moduleClass = getattr(content, 'Page')
>                               if not moduleClass:
>                                       raise Exception, "Unable to find Page 
> object."
>                               classInstance = moduleClass(atom.id, model)
>                       elif isinstance(atom, model.Directory):
>                               moduleClass = getattr(content, 'Folder')
>                               if not moduleClass:
>                                       raise Exception, "Unable to find Folder 
> object."
>                               classInstance = moduleClass(atom.id, model)
>                       if atom.Children is not None:
>                               self._descend(classInstance, atom)
>                       setattr(base, atom.Name.replace('-', '_'), 
> classInstance)
>       ...

It'll change (i.e. I'll remove the if/elif statements) once I can
aggregate the content modules.

Reply via email to