Top Level Document
Is there a need for a top level Document for all objects to reference as thier ownerDocument?
- Further investigation shows a class called Root defined in ZDOM.py. This class is a base class for the Application.
- Which is wrong, as Amos has pointed out to us
several times. Sigh.
Of course, this doen't really have anything to do with whether there should be a top-level document.
- Having a Document as the "Parent" class will not work well in Zope. A document is only allowed one element child, the document element. what we really neeed to say is that the application is trhe document element.
- You need to tell us whether Zope needs to have a
If the answer is yes, then it should be provided as a sub-object defined in (a base class of) the Aplication class. Something like:
In ZDOM.py or some such:
class ZopeDocument(Acquisition.Implicit, ...): """Implement the document interface For the document that is Zope. :) """ # Note that we get at our top-level element # and the rest of the object system though # aq_parent, which we get because we acquire. ... class ZopeTopLevelElement(...): OwnerDocument=ZopeDocument() ....
class Application(..., ZDOM.ZopeTopLevelElement, ...): ...
- This is the way I have implemented it. A super class of element called RootElement? is a base class for application. The root element needs to be a special case, not for owner document support, but because it is the acuisition parent of all other nodes hence its parentNode attribute functions differently. I create a singleton Document for the Application when it is first created.
- The singleton should be defined in the class.
There's no reason to store it in the application object.
- It is not. It is defined in RootElement?.py as a singleton.