[Zope] too much different object types?

Joachim Werner joe@iuveno-net.de
Thu, 31 May 2001 16:07:53 +0200


> I have a problem to understand why there are so much different object
types
> in Zope and why you can't access more general categories of objects. I
found
> that it is not logic. If Zope is based on objects, he has to group some
> objects in more general classes together, so you can access Folder,
> Documents, Scripts and Images.
> Folder and Image classes exist, but a class Document which is an super
class
> for the types Files, XML Document, DTML Document, etc. does not exist, as
> well as a class Script which could be an super class for Python scripts,
> DTML Methode, etc.
> i understand that zope needs a precise type for each object, but why can i
> not access a more general categorie of objects?

Hi Isabelle!

Zope is using "mix-in" classes, or in other words, Python multiple
inheritance, so most objects are built from a toolkit of basic objects. E.g.
this is from Image.py, which defines the image and file objects:

import Globals, string, struct, content_types
from OFS.content_types import guess_content_type
from Globals import DTMLFile, MessageDialog
from PropertyManager import PropertyManager
from AccessControl.Role import RoleManager
from webdav.common import rfc1123_date
from SimpleItem import Item_w__name__
from cStringIO import StringIO
from Globals import Persistent
from Acquisition import Implicit
from DateTime import DateTime
from Cache import Cacheable

With these building blocks, mainly SimpleItem and PropertyManager, a Zope
object can be built.

Image is then just a subclass of File that implements the differences, e.g.
a tab for displaying the image, the code for rendering it as an html "<img
src ...>" string etc.:

"class Image(File)"

So the concept of base classes is certainly there, but maybe a bit different
than you'd expect ... (the "Document" base class is more or less what
"SimpleItem" does, and the reason why DTMLDocument (which is just DTMLMethod
plus PropertyManager ("class DTMLDocument(PropertyManager, DTMLMethod)") is
not inherited from something like "Document", which might be a base class
for XMLDocument, is just that it doesn't seem to share enough code to make
this necessary.

If you dig into Zope's code, you'll see that some parts are not very nice
style. But they work, and that's the most important thing ;-)

Joachim