[Zope3-Users] "Forbidden Attribute" errors whilst adapting to
schema
Rupert Redington
rupert at neontribe.co.uk
Fri Feb 3 05:20:50 EST 2006
Morning (if it is for you)...
I've been trying to write an adapter which stores data submitted by a
schema generated form into the annotations on an object. I've been
guided in this by both Stephan's and Philipp's books (though neither
provide an example of what I'm trying to do). My unit tests indicate
that my adapter functions correctly. But when I try to access a
browser:editForm for the schema I receive the traceback below. I've made
several attempts to work around/though the errors, but I soon find
myself out of my depth in a world of LocationProxys.
I've written the simplest example that I can - but I'm not sure that it
would be acceptable to attach a tarball to a mail to this list. I've put
it up here: http://www.neontribe.co.uk/~rupert/adaptertest.tar.bz2
Figuring that, since my unittests run, I've probably misconfigured
myself into a permissions problem I've also included the ZCML from my
example.
Thanks in advance for any advice
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:i18n="http://namespaces.zope.org/i18n"
i18n_domain="adaptertest">
<interface
interface=".interfaces.ILink"
type="zope.app.content.interfaces.IContentType"
/>
<content class=".link.Link">
<implements
interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
/>
<factory
id="adaptertest.link.Link"
description="Link"
/>
<require
permission="zope.View"
interface=".interfaces.ILink"
/>
<require
permission="zope.ManageContent"
set_schema=".interfaces.ILink"
/>
</content>
<adapter
for=".interfaces.ILink"
provides=".interfaces.ILinkDetails"
factory=".link.LinkDetails"
trusted="True"
/>
<include package=".browser"/>
</configure>
.browser/configure.zcml
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="adaptertest">
<browser:addform
label="Add Link"
name="AddLink.html"
schema="adaptertest.interfaces.ILink"
content_factory="adaptertest.link.Link"
fields="url"
permission="zope.ManageContent"
/>
<browser:addMenuItem
class="adaptertest.link.Link"
title="Link"
permission="zope.ManageContent"
view="AddLink.html"
/>
<browser:editform
schema="adaptertest.interfaces.ILink"
for="adaptertest.interfaces.ILink"
label="Edit Link"
fields="url"
name="edit.html"
permission="zope.ManageContent"
menu="zmi_views"
title="Edit"
/>
<!-- add a page to handle the ILinkDetails adapter -->
<browser:editform
schema="adaptertest.interfaces.ILinkDetails"
for="adaptertest.interfaces.ILink"
label="Edit Details"
fields="description"
name="editDetails.html"
permission="zope.ManageContent"
menu="zmi_views"
title="Edit Details"
/>
</configure>
Error type: zope.security.interfaces.ForbiddenAttribute
Error object: ('description', <adaptertest.link.LinkDetails object at
0xb62ad8ec>)
File "/home/rupert/Zope3/lib/python/zope/publisher/publish.py", line
135, in publish
object = request.traverse(object)
File "/home/rupert/Zope3/lib/python/zope/publisher/browser.py",
line 500, in traverse
ob = super(BrowserRequest, self).traverse(object)
File "/home/rupert/Zope3/lib/python/zope/publisher/http.py", line
451, in traverse
ob = super(HTTPRequest, self).traverse(object)
File "/home/rupert/Zope3/lib/python/zope/publisher/base.py", line
289, in traverse
subobject = publication.traverseName(
File
"/home/rupert/Zope3/lib/python/zope/app/publication/publicationtraverse.py",
line 46, in traverseName
ob2 = namespaceLookup(ns, nm, ob, request)
File
"/home/rupert/Zope3/lib/python/zope/app/traversing/namespace.py", line
121, in namespaceLookup
return traverser.traverse(name, ())
File
"/home/rupert/Zope3/lib/python/zope/app/traversing/namespace.py", line
363, in traverse
name=name)
File "/home/rupert/Zope3/lib/python/zope/component/__init__.py",
line 165, in queryMultiAdapter
return sitemanager.queryMultiAdapter(objects, interface, name, default)
File "/home/rupert/Zope3/lib/python/zope/component/site.py", line
75, in queryMultiAdapter
default)
File "/home/rupert/Zope3/lib/python/zope/interface/adapter.py",
line 475, in queryMultiAdapter
return factory(*objects)
File
"/home/rupert/Zope3/lib/python/zope/app/form/browser/editview.py", line
64, in __init__
self._setUpWidgets()
File
"/home/rupert/Zope3/lib/python/zope/app/form/browser/editview.py", line
69, in _setUpWidgets
names=self.fieldNames)
File "/home/rupert/Zope3/lib/python/zope/app/form/utility.py",
line 187, in setUpEditWidgets
value = field.get(source)
File
"/home/rupert/Zope3/lib/python/zope/schema/_bootstrapfields.py", line
171, in get
return getattr(object, self.__name__)
More information about the Zope3-users
mailing list