Hello,

I just recently started trying out Zope 3.  My first test project is a
few containers that can contain other containers or an object.  They are
laid out as follows:

FosterRecord
-> FosterSource
    -> Foster
    -> FosterGroup
       -> Foster

A FosterRecord is the top level container and can contain a
FosterSource.  A FosterSource can contain a Foster object or a
FosterGroup.  And a FosterGroup can contain a Foster object.

I setup this relationship with IContainer and IContained interfaces and
calls to contains() and containers().

I start adding containers and objects to create this structure through
the ZMI.  When I am ready to add a FosterGroup or a Foster to a
FosterSource, I do not get any options for them in the add menu.  I
haven't been able to find what is causing it.  I would guess it has
something to do with the constraints.

I am running this on Zope 3.3.0b2.  I am attaching my interfaces.py,
foster.py and configure.zcml.  Does anyone know what is causing this
problem?  Also, since I am new to Zope, does anyone have any suggestions
on a better or cleaner way of implementing this?  Thank you.

--
Rob Campbell

from zope.interface import Interface
from zope.schema import Text, TextLine, Int, Date, Bool, Choice, Field
from zope.app.container.constraints import containers, contains
from zope.app.container.interfaces import IContainer, IContained

class IFosterRecord(Interface):
  """A FosterRecord.
  """

  title = TextLine(
    title=u'Title',
    description=u'Title of FosterRecord',
    required=True
  )

class IFosterSource(Interface):
  """A FosterSource.
  """

  title = TextLine(
    title=u'Title',
    description=u'Title of FosterSource',
    required=True
  )

class IFosterGroup(Interface):
  """A FosterGroup.
  """

  title = TextLine(
    title=u'Title',
    description=u'Title of FosterSource',
    required=True
  )

class IFoster(Interface):
  """Information about a foster.
  """

#  id = Int(
#    title=u'Foster ID',
#    description=u'ID number of the foster',
#    required=True
#  )

  nickname = TextLine(
    title=u'Nickname',
    description=u'Nickname of the foster',
    required=False
  )

  history = Text(
    title=u'History',
    description=u'History of the foster',
    required=False
  )

  markings = Text(
    title=u'Markings',
    description=u'The foster\'s markings',
    required=True
  )

  personality = Text(
    title=u'Personality',
    description=u'Personality of the foster',
    required=False
  )

  health = Choice(
    title=u'Health',
    description=u'Health of the foster',
    values=('Good', 'Minor', 'Major', 'Undetermined'),
    required=True
  )

  healthInfo = Text(
    title=u'Health Information',
    description=u'Additional health information',
    required=False
  )

  bornOn = Date(
    title=u'Born On',
    description=u'Date on which foster was born',
    required=True
  )

  bornApprox = Bool(
    title=u'Approx.',
    description=u'Approximate date',
    required=True
  )

  gender = Choice(
    title=u'Gender',
    description=u'Gender of the foster',
    values=('Male', 'Female', 'Undetermined'),
    required=True
  )

  fixed = Bool(
    title=u'Fixed',
    description=u'If the foster has been fixed',
    required=True
  )

  fixedOn = Date(
    title=u'Fixed On',
    description=u'Date the foster was fixed',
    required=False
  )

  receivedOn = Date(
    title=u'Received On',
    description=u'Date the foster was received',
    required=True
  )

  adoptedOn = Date(
    title=u'Adopted On',
    description=u'Date the foster was adopted',
    required=False
  )

  adoptedBy = TextLine(
    title=u'Adopted By',
    description=u'Person who adopted the foster',
    required=False
  )

  pregnancyWatch = Choice(
    title=u'Pregnancy Watch',
    description=u'Pregnancy watch status',
    values=('On', 'Cleared', 'Pregnant', 'N/A'),
    required=True
  )

  pregnancyWatchEndsOn = Date(
    title=u'Pregnancy Watch Ends On',
    description=u'Date when pregnancy watch expires',
    required=False
  )

  transferedOn = Date(
    title=u'Ttransfered On',
    description=u'Date of transfer',
    required=False
  )

  transferedTo = TextLine(
    title=u'Transfered To',
    description=u'Person to which foster was transfered',
    required=False
  )

class IFosterRecordContained(IContained):
  """Implemented by objects that can be contained in a FosterRecord.
  """

  containers(IFosterRecord)

class IFosterSourceContainer(IContainer):
  """Implemented by objects that can contain a FosterSource.
  """

  contains(IFosterSource)

class IFosterSourceContained(IContained):
  """Implemented by objects that can be contained in a FosterSource.
  """

  containers(IFosterSourceContainer)

class IFosterGroupContainer(IContainer):
  """Implemented by objects that can contain a FosterGroup.
  """

  contains(IFosterGroup)

class IFosterGroupContained(IContained):
  """Implemented by objects that can be contained in a FosterGroup.
  """

  containers(IFosterGroupContainer)

class IFosterContainer(IContainer):
  """Implemented by objects that can contain a Foster.
  """

  contains(IFoster)


from zope.interface import implements
from zope.schema.fieldproperty import FieldProperty
from zope.app.container.btree import BTreeContainer
from zope.app.container.contained import Contained, NameChooser
from interfaces import IFosterRecord, IFosterSource, IFosterGroup, IFoster
from interfaces import IFosterRecordContained, IFosterSourceContained, IFosterGroupContained
from interfaces import IFosterSourceContainer, IFosterGroupContainer, IFosterContainer

class FosterRecord(BTreeContainer):
  """A FosterRecord.
  """

  implements(IFosterRecord, IFosterSourceContainer)

  title = FieldProperty(IFosterRecord['title'])

class FosterSource(BTreeContainer, Contained):
  """A FosterSource.
  """

  implements(IFosterSource, IFosterRecordContained, IFosterGroupContainer, IFosterContainer)

  title = FieldProperty(IFosterSource['title'])

class FosterGroup(BTreeContainer, Contained):
  """A FosterGroup.
  """

  implements(IFosterGroup, IFosterSourceContained, IFosterContainer)

  title = FieldProperty(IFosterGroup['title'])

class Foster(Contained):
  """A Foster.
  """

  implements(IFoster, IFosterSourceContained, IFosterGroupContained)

#  id = FieldProperty(IFoster['id'])
  nickname = FieldProperty(IFoster['nickname'])
  history = FieldProperty(IFoster['history'])
  markings = FieldProperty(IFoster['markings'])
  personality = FieldProperty(IFoster['personality'])
  health = FieldProperty(IFoster['health'])
  healthInfo = FieldProperty(IFoster['healthInfo'])
  bornOn = FieldProperty(IFoster['bornOn'])
  bornApprox = FieldProperty(IFoster['bornApprox'])
  gender = FieldProperty(IFoster['gender'])
  fixed = FieldProperty(IFoster['fixed'])
  fixedOn = FieldProperty(IFoster['fixedOn'])
  receivedOn = FieldProperty(IFoster['receivedOn'])
  adoptedOn = FieldProperty(IFoster['adoptedOn'])
  adoptedBy = FieldProperty(IFoster['adoptedBy'])
  pregnancyWatch = FieldProperty(IFoster['pregnancyWatch'])
  pregnancyWatchEndsOn = FieldProperty(IFoster['pregnancyWatchEndsOn'])
  transferedOn = FieldProperty(IFoster['transferedOn'])
  transferedTo = FieldProperty(IFoster['transferedTo'])


<configure
  xmlns='http://namespaces.zope.org/zope'
  xmlns:browser='http://namespaces.zope.org/browser'
  i18n_domain='fosters'
  >

  <class class='.foster.FosterRecord'>
    <require
      permission='zope.View'
      interface='.interfaces.IFosterRecord'
    />
    <require
      permission='zope.ManageContent'
      set_schema='.interfaces.IFosterRecord'
    />
    <require
      permission='zope.View'
      interface='zope.app.container.interfaces.IReadContainer'
    />
    <require
      permission='zope.ManageContent'
      interface='zope.app.container.interfaces.IWriteContainer'
    />
  </class>

  <browser:containerViews
    for='.interfaces.IFosterRecord'
    add='zope.ManageContent'
    contents='zope.View'
    index='zope.View'
  />

  <browser:addMenuItem
    class='.foster.FosterRecord'
    title='Foster Records'
    view='addFosterRecord.html'
    permission='zope.ManageContent'
  />

  <browser:page
    for='zope.app.container.interfaces.IAdding'
    name='addFosterRecord.html'
    class='.browser.FosterRecordAddView'
    permission='zope.ManageContent'
  />
<!--
  <browser:page
    for='.interfaces.IFosterRecord'
    name='edit.html'
    class='.browser.FosterRecordEditView'
    permission='zope.ManageContent'
  />

  <browser:page
    for='.interfaces.IFosterRecord'
    name='index.html'
    class='.browser.FosterRecordDisplayView'
    permission='zope.View'
  />
-->
  <browser:page
    for='.interfaces.IFosterRecord'
    name='SelectedManagementView.html'
    class='.browser.FosterRecordEditView'
    permission='zope.ManageContent'
  />

  <class class='.foster.FosterSource'>
    <require
      permission='zope.View'
      interface='.interfaces.IFosterSource'
    />
    <require
      permission='zope.ManageContent'
      set_schema='.interfaces.IFosterSource'
    />
    <require
      permission='zope.View'
      interface='zope.app.container.interfaces.IReadContainer'
    />
    <require
      permission='zope.ManageContent'
      interface='zope.app.container.interfaces.IWriteContainer'
    />
  </class>

  <browser:containerViews
    for='.interfaces.IFosterSource'
    add='zope.ManageContent'
    contents='zope.View'
    index='zope.View'
  />

  <browser:addMenuItem
    class='.foster.FosterSource'
    title='Foster Source'
    view='addFosterSource.html'
    permission='zope.ManageContent'
  />

  <browser:page
    for='zope.app.container.interfaces.IAdding'
    name='addFosterSource.html'
    class='.browser.FosterSourceAddView'
    permission='zope.ManageContent'
  />
<!--
  <browser:page
    for='.interfaces.IFosterSource'
    name='edit.html'
    class='.browser.FosterSourceEditView'
    permission='zope.ManageContent'
  />

  <browser:page
    for='.interfaces.IFosterSource'
    name='index.html'
    class='.browser.FosterSourceDisplayView'
    permission='zope.View'
  />
-->
  <browser:page
    for='.interfaces.IFosterSource'
    name='SelectedManagementView.html'
    class='.browser.FosterSourceEditView'
    permission='zope.ManageContent'
  />

  <class class='.foster.FosterGroup'>
    <require
      permission='zope.View'
      interface='.interfaces.IFosterGroup'
    />
    <require
      permission='zope.ManageContent'
      set_schema='.interfaces.IFosterGroup'
    />
    <require
      permission='zope.View'
      interface='zope.app.container.interfaces.IReadContainer'
    />
    <require
      permission='zope.ManageContent'
      interface='zope.app.container.interfaces.IWriteContainer'
    />
  </class>

  <browser:containerViews
    for='.interfaces.IFosterGroup'
    add='zope.ManageContent'
    contents='zope.View'
    index='zope.View'
  />

  <browser:addMenuItem
    class='.foster.FosterGroup'
    title='Foster Group'
    view='addFosterGroup.html'
    permission='zope.ManageContent'
  />

  <browser:page
    for='zope.app.container.interfaces.IAdding'
    name='addFosterGroup.html'
    class='.browser.FosterGroupAddView'
    permission='zope.ManageContent'
  />
<!--
  <browser:page
    for='.interfaces.IFosterGroup'
    name='edit.html'
    class='.browser.FosterGroupEditView'
    permission='zope.ManageContent'
  />

  <browser:page
    for='.interfaces.IFosterGroup'
    name='index.html'
    class='.browser.FosterGroupDisplayView'
    permission='zope.View'
  />
-->
  <browser:page
    for='.interfaces.IFosterGroup'
    name='SelectedManagementView.html'
    class='.browser.FosterGroupEditView'
    permission='zope.ManageContent'
  />

  <class class='.foster.Foster'>
    <require
      permission='zope.View'
      interface='.interfaces.IFoster'
    />
    <require
      permission='zope.ManageContent'
      set_schema='.interfaces.IFoster'
    />
  </class>

  <browser:addMenuItem
    class='.foster.Foster'
    title='Foster'
    view='addFoster.html'
    permission='zope.ManageContent'
  />

  <browser:page
    for='zope.app.container.interfaces.IAdding'
    name='addFoster.html'
    class='.browser.FosterAddView'
    permission='zope.ManageContent'
  />

  <browser:page
    for='.interfaces.IFoster'
    name='edit.html'
    class='.browser.FosterEditView'
    permission='zope.ManageContent'
  />

  <browser:page
    for='.interfaces.IFoster'
    name='index.html'
    class='.browser.FosterDisplayView'
    permission='zope.View'
  />

  <browser:page
    for='.interfaces.IFoster'
    name='SelectedManagementView.html'
    class='.browser.FosterEditView'
    permission='zope.ManageContent'
  />

</configure>

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

Reply via email to