I get reasonable edit screens for my car and driver classes when I use a url like "limoService/car1/edit.html" but when I try to add the edit screens as zmi menu entries I get an error:

File "C:\Python24\Lib\site-packages\zope\app\publisher\browser\menu.py", line 62, in getMenuItems
    result = [(ifaces.index(item._for or Interface),
ValueError: list.index(x): x not in list

The complete call stack is in the attached error.txt. I'm using v3.3.1 under winxpprosp2. What am I doing wrong?

Thanks,
John

<configure
    xmlns="http://namespaces.zope.org/zope";
    xmlns:browser="http://namespaces.zope.org/browser";
        i18n_domain="limoService"
        >
        
  <interface
      interface=".interfaces.ICar"
      type="zope.app.content.interfaces.IContentType"
      />
  <interface
      interface=".interfaces.IDriver"
      type="zope.app.content.interfaces.IContentType"
      />

  <class class=".classes.Car">
    <implements
        interface="zope.annotation.interfaces.IAttributeAnnotatable"
        />
    <factory
        id="limoService.classes.Car"
        description="a car" 
        />
    <require
        permission="zope.Public"
        interface=".interfaces.ICar"
        />
    <require
        permission="zope.ManageContent"
        set_schema=".interfaces.ICar"
        />
  </class>
  <class class=".classes.Driver">
    <implements
        interface="zope.annotation.interfaces.IAttributeAnnotatable"
        />
    <factory
        id="limoService.classes.Driver"
        description="a driver" 
        />
    <require
        permission="zope.Public"
        interface=".interfaces.IDriver"
        />
    <require
        permission="zope.ManageContent"
        set_schema=".interfaces.IDriver"
        />
  </class>

  <browser:addMenuItem
      class=".classes.Car"
      title="a car"
      permission="zope.ManageContent"
      description="add Car"
  />
  <browser:addMenuItem
      class=".classes.Driver"
      title="a driver"
      permission="zope.ManageContent"
      description="add Driver"
  />

  <browser:page
    for="zope.app.container.interfaces.IAdding"
    name="newdriver"
    class=".classes.DriverAddForm"
    permission="zope.ManageContent"
        menu="zmi_views" title="newdriver"
    />


  <browser:page
      for=".classes.Car"
      name="index.html"
      class=".classes.CarView"
      permission="zope.Public"
          template="read.pt"
          menu="zmi_views" title="view"
      />
  <browser:page
      for=".classes.Driver"
      name="index.html"
      class=".classes.DriverView"
      permission="zope.Public"
          template="read.pt"
          menu="zmi_views" title="view"
      />

  <browser:page
      for=".interfaces.ICar"
      name="edit.html"
      class=".classes.CarEdit"
      permission="zope.ManageContent"
      template="edit.pt"
          menu="zmi_views" title="edit"
      />
  <browser:page
      for=".interfaces.IDriver"
      name="edit.html"
      class=".classes.DriverEdit"
      permission="zope.ManageContent"
      template="edit.pt"
          menu="zmi_views" title="edit"
          />

  <utility
      provides="zope.schema.interfaces.IVocabularyFactory"
      component=".classes.carsInParent"
      name="allCars"
      />

  <interface
      interface=".interfaces.ILimoservice"
      type="zope.app.content.interfaces.IContentType"
      />
  
  <class class=".classes.Limoservice">
    <implements
        interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
        />
    <implements
        interface="zope.app.container.interfaces.IContentContainer" 
        />
    <factory
        id="limoService.classes.Limoservice"
        description="Limoservice" 
        />
    <require
        permission="zope.ManageContent"
        interface=".interfaces.ILimoservice"
        />
    <require
        permission="zope.ManageContent"
        set_schema=".interfaces.ILimoservice"
        />
  </class>
  
  <browser:addMenuItem
      class=".classes.Limoservice"
      title="Limoservice"
      permission="zope.ManageContent"
  />
  <browser:containerViews
      for="limoService.interfaces.ILimoservice"
      index="zope.View"
      contents="zope.View"
      add="zope.ManageContent"
      />

  </configure>
from zope.interface import Interface
from zope.schema import Field, Text, TextLine, Choice, Int, Bool, Date, 
Datetime, Object
from zope.schema.vocabulary import SimpleVocabulary

from zope.app.container.constraints import ContainerTypesConstraint
from zope.app.container.constraints import ItemTypePrecondition
from zope.app.container.interfaces import IContained, IContainer

class ICar(Interface):
        model = TextLine(
                title = u'model',
                description = u'model',
                default = u'',
                required = False)
        nPassengers = Int(
                title = u'nPassengers',
                description = u'nPassengers',
                default = 0,
                required = False)

class IDriver(Interface):
        car = Choice(
                title = u'car',
                description = u'car',
                default = None,
                source = 'allCars',
                required = False)

class ILimoservice(IContainer):
        '''container for items of type ICar, IDriver'''
        name = TextLine(
                title=u'Limoservice',
                description=u'a Limoservice container',
                default=u'',
                required=True)
        def __setitem__(name, obj): pass 
        __setitem__.precondition = ItemTypePrecondition(ICar, IDriver)

class ILimoserviceContained(IContained):
        '''for types that can only be contained in a Limoservice'''
        __parent__ = Field(constraint = ContainerTypesConstraint(ILimoservice))
from zope.app import zapi
from zope.interface import implements
from zope.app.container.btree import BTreeContainer
from zope.app.container.contained import Contained
# from persistent import Persistent

from interfaces import ICar, IDriver, ILimoservice, ILimoserviceContained

class Car(Contained):
        implements(ICar,ILimoserviceContained)
        model=u''
        nPassengers=0

class Driver(Contained):
        implements(IDriver,ILimoserviceContained)
        car=None

class Limoservice(BTreeContainer):
        implements(ILimoservice)

class CarView(object):
    def message(self):
        return 'car model %s holds %d passengers' % (self.context.model, 
self.context.nPassengers)
class DriverView(object):
        def message(self):
                if self.context.car:
                        car=self.context.car
                        msg='driver drives car model %s, can carry %d 
passengers' % (car.model,car.nPassengers)
                else:
                        print 'driver has no car!'
                        msg='no car info'
                return msg

from zope.formlib import form
class CarEdit(form.EditForm):
        form_fields = form.Fields(ICar)
class DriverEdit(form.EditForm):
        form_fields = form.Fields(IDriver)

class DriverAddForm(form.AddForm):
        form_fields = form.Fields(IDriver)

from zope.schema.vocabulary import SimpleVocabulary
def carsInParent(context):
    '''returns child cars __name__ for subobjects of parent as a vocabulary'''
    return SimpleVocabulary.fromItems(
        [(k, v) for k, v in context.__parent__.items() if ICar.providedBy(v)])

2008-01-14T09:13:39 ERROR SiteError 
http://localhost:2020/mylimo/c1/@@SelectedManagementView.html
Traceback (most recent call last):
  File "C:\Python24\Lib\site-packages\zope\publisher\publish.py", line 133, in 
publish
    result = publication.callObject(request, obj)
  File "C:\Python24\Lib\site-packages\zope\app\publication\zopepublication.py", 
line 161, in callObject
    return mapply(ob, request.getPositionalArguments(), request)
  File "C:\Python24\Lib\site-packages\zope\publisher\publish.py", line 108, in 
mapply
    return debug_call(obj, args)
   - __traceback_info__: <security proxied 
zope.app.publisher.browser.viewmeta.ManagementViewSelector instance at 
0x022384B0>
  File "C:\Python24\Lib\site-packages\zope\publisher\publish.py", line 114, in 
debug_call
    return obj(*args)
  File 
"C:\Python24\Lib\site-packages\zope\app\publisher\browser\managementviewselector.py",
 line 35, in __call__
    item = getFirstMenuItem('zmi_views', self.context, self.request)
  File "C:\Python24\Lib\site-packages\zope\app\publisher\browser\menu.py", line 
181, in getFirstMenuItem
    items = getMenu(id, object, request)
  File "C:\Python24\Lib\site-packages\zope\app\publisher\browser\menu.py", line 
176, in getMenu
    return menu.getMenuItems(object, request)
  File "C:\Python24\Lib\site-packages\zope\app\publisher\browser\menu.py", line 
62, in getMenuItems
    result = [(ifaces.index(item._for or Interface),
ValueError: list.index(x): x not in list
127.0.0.1 - - [14/Jan/2008:09:13:39 -0400] "GET 
/mylimo/c1/@@SelectedManagementView.html HTTP/1.1" 500 84 
"http://localhost:2020/mylimo/@@contents.html"; "Mozilla/5.0 (Windows; U; 
Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to