[Zope3-Users] Create complex object

Achim Domma domma at procoders.net
Wed May 24 20:45:04 EDT 2006


Hi,

I have the this interface

class IWorkspace(Interface):
     title = TextLine(
        title=u"Title",
        description=u"The title",
        default=u"proCoders Workspace",
        required=True)
     projects = Container(title=u"Projects", description=u"xxx")
     articles = Container(title=u"Articles", description=u"xxx")

with the following implementation

class Workspace(Persistent):
     implements(IWorkspace)
     title=u'proCoders workspace'
     projects=None
     articles=None

To set projects and articles I have registered an event subscriber. The 
handling functions is defined like this:

def onObjectCreated(parent,event):
     if IWorkspace.providedBy(event.object):
         workspace=IWorkspace(event.object)
         workspace.projects=ProjectFolder()
         workspace.articles=ArticleFolder()

I registered an add form with the following zcml statement:

<browser:addform
     label="Add proCoders Article"
     name="AddArticle.html"
     schema="proCoders.interfaces.IArticle"
     content_factory="proCoders.Article.Article"
     permission="zope.ManageContent"
     fields="title"
     />

I added the fields="title" attribute, because I get the following error, 
if I try to create an instance of Workspace:

ComponentLookupError: ((<zope.schema._bootstrapfields.Container object ...

It's clear to me, that the widgets for projects and articles can not be 
created, but I tought that if I set fields="title" I will not show them!?

How do I solve this problem? Should I implement a mix-in class for the 
add view?

regards,
Achim


More information about the Zope3-users mailing list