re: Subclassing ZObjectManager in ZClasses
re: http://lists.zope.org/pipermail/zope-dev/2000-March/004034.html This message is about 1.5 years old, but no replies?, & I haven't seen any similar messages or howtos? --Alexandre Ratti Fri, 31 Mar 2000
Summary: (when creating a folderish ZClass and cascading base classes) if ZObjectManager isn't subclassed at 1st level, objects can be added to the folderish ZClass instances but they don't show in the manage_main object list.
Here I first created MyBaseClass, then I subclassed it together with ZObjectManager when creating MyTestClass ... when I add objects in an instance of MyTestClass they do not show in the object list (Content view). I *think* they are actually added because I cannot add an additional one with the same ID: I get an "ID already in use" error.
It's not that bad, but I can't create a standard base class, then use it to create a folderish variant.
I have the same symptoms, objects dont display in a folder subclass, but are there. Heres how I fixed it: Your base class must be the last in the class inheritance list. You must add all other base classes first. This will almost always be a problem because most base classes start with ZClass... and will be last alphabetically. (this will be much easier to fix if/when you can change, or at least reorder, the base classes of an object) eg: ZObject, ZObjectManager, CatalogAwareBase, MyBaseClass If you have a complicated object, I think you can export it in XML, reorder the base classes, & reimport. But adding/removing classes this way doesn't update the management interface tabs. Daniel Rogahn drogahn@d.umn.edu http://www.d.umn.edu/~drogahn/
Daniel Rogahn writes:
....
Summary: (when creating a folderish ZClass and cascading base classes) if ZObjectManager isn't subclassed at 1st level, objects can be added to the folderish ZClass instances but they don't show in the manage_main object list. I can explain, why it happens. I think it is a bug, at least a mis-feature. But I cannot change it :-(
"OFS.SimpleItem.Item" provides stupid (!) implementations of "objectItems", "objectIds" and "objectValues" (all return the empty tuple). I do not know, why in hell a non-ObjectManager implements ObjectManager methods. Because it does, you get the behaviour you complain about. "OFS.SimpleItem.Item" is essentially what is called "ZObject" in ZClasses and what you get when the "Include standard Zope object behavior" is checked. When your class (deriving von ZObject) comes before "ZObjectManager", then its stupid "objectItems" method is inherited and not that of "ZObjectManager". This changes, when you switch the inheritance order. The solution: "OFS.SimpleItem.Item" should not define ObjectManager methods. Unfortunately, many "dtml-tree" applications will probably break then. Affected will be "dtml-tree" occurences with "branches=objectValues". Dieter
participants (2)
-
Daniel Rogahn -
Dieter Maurer