Hi all,

I'm a newbie to zope3, but I've been looking through google, the zope3 apidoc, the books by weithershausen and richter and can't find the solution to my problem.


I've added two items to the zmi_views menu. One is an browser:editform (named AddProject.html), and the other is a browser:page (named ViewProject.html).

If I don't add the menu="zmi_views" title="ViewIt" to the ViewProject.html page directive in the configure.zcml file and visit http://localhost:8090/testproject/ViewProject.html, the page displays perfectly.

testproject is an instance of the finance.project.Project class. Withouth the ViewProject.html page, the addForm and editForm work ok, and all three work ok if I don't add the ViewProject.html to the zmi_views menu

If I add the menu="zmi_views" title="ViewIt" to the browser:page directive, I get an error when visiting the same page. The error is a "ValueError: list.index(x): x not in list", which does not mean much I guess. The full trace does not help me much more though (it is listed below), it just tells me something goes wrong generating the menu. But I don't get what goes wrong.

I guess it is just something simple, but I can't find what. Who can help? My packages configure.zcml,browser/configure.zcml and projectview.pt files are below the error trace.


Time
Tue Jul 11 20:28:02 2006
User
admin, zope.manager, Manager,
Request URL
http://localhost:8090/testproject/ViewProject.html
Exception type
ValueError
Exception value
list.index(x): x not in list
Traceback


Traceback (innermost last):

    * Module zope.publisher.publish, line 138, in publish
      result = publication.callObject(request, object)
    * Module zope.app.publication.zopepublication, line 161, in callObject
      return mapply(ob, request.getPositionalArguments(), request)
    * Module zope.publisher.publish, line 113, in mapply
      return debug_call(object, args)
__traceback_info__: <security proxied zope.app.pagetemplate.simpleviewclass.SimpleViewClass from /home/dolf/opt/zope/lib/python/finance/browser/projectview.pt instance at 0xb5e5882c>
    * Module zope.publisher.publish, line 119, in debug_call
      return object(*args)
    * Module zope.app.pagetemplate.simpleviewclass, line 44, in __call__
      return self.index(*args, **kw)
* Module zope.app.pagetemplate.viewpagetemplatefile, line 83, in __call__
      return self.im_func(im_self, *args, **kw)
* Module zope.app.pagetemplate.viewpagetemplatefile, line 51, in __call__
      sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
    * Module zope.pagetemplate.pagetemplate, line 117, in pt_render
      strictinsert=0, sourceAnnotations=sourceAnnotations)()
    * Module zope.tal.talinterpreter, line 277, in __call__
      self.interpret(self.program)
    * Module zope.tal.talinterpreter, line 352, in interpret
      handlers[opcode](self, args)
    * Module zope.tal.talinterpreter, line 908, in do_useMacro
      self.interpret(macro)
    * Module zope.tal.talinterpreter, line 352, in interpret
      handlers[opcode](self, args)
    * Module zope.tal.talinterpreter, line 538, in do_optTag_tal
      self.do_optTag(stuff)
    * Module zope.tal.talinterpreter, line 523, in do_optTag
      return self.no_tag(start, program)
    * Module zope.tal.talinterpreter, line 518, in no_tag
      self.interpret(program)
    * Module zope.tal.talinterpreter, line 352, in interpret
      handlers[opcode](self, args)
    * Module zope.tal.talinterpreter, line 878, in do_defineMacro
      self.interpret(macro)
    * Module zope.tal.talinterpreter, line 352, in interpret
      handlers[opcode](self, args)
    * Module zope.tal.talinterpreter, line 976, in do_defineSlot
      self.interpret(block)
    * Module zope.tal.talinterpreter, line 352, in interpret
      handlers[opcode](self, args)
    * Module zope.tal.talinterpreter, line 538, in do_optTag_tal
      self.do_optTag(stuff)
    * Module zope.tal.talinterpreter, line 523, in do_optTag
      return self.no_tag(start, program)
    * Module zope.tal.talinterpreter, line 518, in no_tag
      self.interpret(program)
    * Module zope.tal.talinterpreter, line 352, in interpret
      handlers[opcode](self, args)
    * Module zope.tal.talinterpreter, line 872, in do_condition
      self.interpret(block)
    * Module zope.tal.talinterpreter, line 352, in interpret
      handlers[opcode](self, args)
    * Module zope.tal.talinterpreter, line 839, in do_loop_tal
      iterator = self.engine.setRepeat(name, expr)
    * Module zope.tales.tales, line 682, in setRepeat
      expr = self.evaluate(expr)
    * Module zope.tales.tales, line 696, in evaluate
      return expression(self)

/home/dolf/opt/zope/lib/python/zope/app/rotterdam/template_tablelayout.pt
      Line 112, Column 24
      Expression: <PathExpr standard:u'context/@@view_get_menu/zmi_views'>
         - Names:
            {'args': (),
             'context': <finance.project.Project object at 0xb5e9c4ec>,
             'default': <object object at 0xb7d67538>,
             'loop': {},
             'nothing': None,
             'options': {},
             'repeat': {},
'request': <zope.publisher.browser.BrowserRequest instance URL=http://localhost:8090/testproject/ViewProject.html>, 'template': <zope.app.pagetemplate.viewpagetemplatefile.ViewPageTemplateFile object at 0xb6bf410c>, 'usage': <zope.pagetemplate.pagetemplate.TemplateUsage object at 0xb5e647ec>, 'view': <zope.app.pagetemplate.simpleviewclass.SimpleViewClass from /home/dolf/opt/zope/lib/python/finance/browser/projectview.pt object at 0xb5e5882c>, 'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper object at 0xb5e61b2c>}
    * Module zope.tales.expressions, line 205, in __call__
      return self._eval(econtext)
    * Module zope.tales.expressions, line 192, in _eval
      ob = self._subexprs[-1](econtext)
    * Module zope.tales.expressions, line 124, in _eval
      ob = self._traverser(ob, element, econtext)
    * Module zope.app.pagetemplate.engine, line 72, in trustedZopeTraverser
      request=getattr(econtext, 'request', None))
    * Module zope.app.traversing.adapters, line 124, in traverse
      curr = traversePathElement(curr, name, path, request=request)
    * Module zope.app.traversing.adapters, line 177, in traversePathElement
      return traversable.traverse(nm, further_path)
    * Module zope.app.traversing.adapters, line 58, in traverse
      return subject[name]
__traceback_info__: (<zope.app.publisher.browser.viewmeta.MenuAccessView object at 0xb5e437ec>, 'zmi_views', [])
    * Module zope.app.publisher.browser.menu, line 193, in __getitem__
      return getMenu(menuId, self.context, self.request)
    * Module zope.app.publisher.browser.menu, line 177, in getMenu
      return menu.getMenuItems(object, request)
    * Module zope.app.publisher.browser.menu, line 63, in getMenuItems
      result = [(ifaces.index(item._for or Interface),

ValueError: list.index(x): x not in list

Laat traceback als tekst zien
REQUEST
wsgi.multiprocess: True
GNOME_DESKTOP_SESSION_ID: Default
SERVER_SOFTWARE: Twisted/2.1.0 TwistedWeb/SVN-Trunk
SCRIPT_NAME: /
LESSOPEN: | /usr/bin/lesspipe %s
REQUEST_METHOD: GET
LOGNAME: dolf
USER: dolf
SERVER_PROTOCOL: HTTP/1.1
QUERY_STRING:
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
DISPLAY: :0.0
SSH_AGENT_PID: 4965
LANG: nl_NL.UTF-8
HTTP_ACCEPT_CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.7
TERM: xterm
SHELL: /bin/bash
XAUTHORITY: /home/dolf/.Xauthority
LANGUAGE: nl:en_GB:en
SESSION_MANAGER: local/dolf-desktop:/tmp/.ICE-unix/4923
SHLVL: 1
wsgi.url_scheme: http
WINDOWID: 33555080
SERVER_PORT: 8090
HOME: /home/dolf
USERNAME: dolf
GDM_XSERVER_LOCATION: local
GTK_RC_FILES: /etc/gtk/gtkrc:/home/dolf/.gtkrc-1.2-gnome2
REMOTE_PORT: 34997
SSH_AUTH_SOCK: /tmp/ssh-GwzJiN4923/agent.4923
DESKTOP_SESSION: default
GDMSESSION: default
wsgi.input:
HTTP_USER_AGENT: Mozilla/5.0 (X11; U; Linux i686; nl; rv:1.8.0.4) Gecko/20060608 Ubuntu/dapper-security Firefox/1.5.0.4
HTTP_HOST: localhost:8090
HTTPS: off
wsgi.multithread: True
wsgi.version: (1, 0)
DBUS_SESSION_BUS_ADDRESS: unix:abstract=/tmp/dbus-JIEWoLH3FP,guid=5952b34473ae97706290129982e1a300
_: bin/runzope
REQUEST_URI: /testproject/ViewProject.html
HTTP_ACCEPT: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
GNOME_KEYRING_SOCKET: /tmp/keyring-oiAS9J/socket
wsgi.file_wrapper: twisted.web2.wsgi.FileWrapper
LESSCLOSE: /usr/bin/lesspipe %s %s
SERVER_NAME: localhost
GATEWAY_INTERFACE: CGI/1.1
wsgi.run_once: False
OLDPWD: /home/dolf/opt/zope/instances
REMOTE_ADDR: 127.0.0.1
HTTP_ACCEPT_LANGUAGE: nl,en-us;q=0.7,en;q=0.3
REQUEST_SCHEME: http
wsgi.errors:
HISTCONTROL: ignoredups
PWD: /home/dolf/opt/zope/instances/instance001
DESKTOP_STARTUP_ID:
COLORTERM: gnome-terminal
SERVER_PORT_SECURE: 0
LS_COLORS: no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.flac=01;35:*.mp3=01;35:*.mpc=01;35:*.ogg=01;35:*.wav=01;35:
HTTP_ACCEPT_ENCODING: gzip,deflate
PATH_INFO: /testproject/ViewProject.html



configure.zcml:

<configure
        xmlns="http://namespaces.zope.org/zope";
        xmlns:browser="http://namespaces.zope.org/browser";
        i18n_domain="en">

        <content class=".project.Project">
                <require
                        attributes="name"
                        permission="zope.Public"
                        />
                <require
                        set_attributes="name"
                        permission="zope.ManageContent"
                        />
                <factory
                        id="finance.Project"
                        title="Add a new project"
                        description="This factory instantiates a new project"
                        />
        </content>
        <include package=".browser" />
</configure>

browser/configure.zcml:

<configure
        xmlns="http://namespaces.zope.org/zope";
        xmlns:browser="http://namespaces.zope.org/browser";
        >
        
        <browser:addMenuItem
                title="Project"
                class="finance.project.Project"
                permission="zope.ManageContent"
                view="AddProject.html"
                />
        <browser:addform
                name="AddProject.html"
                permission="zope.ManageContent"
                label="Add a Project"
                content_factory="finance.project.Project"
                schema="finance.interfaces.IProject"
                />
        <browser:editform
                name="EditProject.html"
                permission="zope.ManageContent"
                menu="zmi_views" title="Edit"
                schema="finance.interfaces.IProject"
                label="Edit the project"
                />
        <browser:page
                name="ViewProject.html"
                permission="zope.Public"
                template="projectview.pt"
                for="finance.project.Project"
                menu="zmi_views" title="ViewIt"
                />
</configure>


browser/projectview.pt:

<html metal:use-macro="context/@@standard_macros/view">
<body>
<div metal:fill-slot="body" tal:content="context/name">
</div>
</body>
</html>

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

Reply via email to