Is this much different from a folder containing either ZPTPages or Folders (not to mention other things)? Have you thought of filtering the views that show lists of one or the other types?

for name, object in folder.items():
    if IType1.providedBy(object):
        ...

Cliff

Alek Kowalczyk wrote:
Hello,

I have a simple (on the first sight) problem, which I don't know how to
resolve in zope3'ish way.

I have a single object, which can contain many objects of 2 another
types (IType1, IType2). My intention is to have those objects contained
in separate collections (because they are very different 2 types of
objects and should not be mixed in one collection)
I'd like to have each collection editable like Zope folder, i.e each
collection to be IContainer/BTreeContainer.

I tried to use the following pattern (which would be natural for pure
python or C++ - i.e. two "Dict"s or two "std::map<string,Type1/2>" objects):

class IMasterObject(Interface):
   objects1 = Object(schema=IObjects1, title=u"Objects of IType1")
   objects2 = Object(schema=IObjects2, title=u"Objects of IType2")

class IObjects1(IContainer):
   pass
   # + constraint to have only objects implementing IType1

class IObjects2(IContainer):
   pass
   # + constraint to have only objects implementing IType2

I have implemented a simple view and created proper ObjectWidgets - no
bigger problems there.
But web interface, after creating MasterObject, shows only empty
fieldset for objects1 and objects2 fields in MasterObject instance. I
don't know how to achieve displaying "Container" view in those fieldsets
instead of "Edit" view.

I have the following questions:
- Is this the proper way to implement an object containing two different
containers/collections of objects and still use 'folder-like' web
interfaces for adding/removing/viewing those collections?
   - If yes, how to display "Container" view in those fieldsets instead
of "Edit" view?
   - If not, how would you suggest to implement this pattern (or its
functional equivalent) in Zope3?

It seems to be pretty common pattern but I couldn't find a solution
anywhere in the book or on the net, so I suspect I was looking for wrong
solution and this should be realized in very another way in Zope3...

Best regards,
Alek Kowalczyk.

_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to