[Zope3-Users] ForbiddenAttribute
Jachin Rupe
jachin at voltzsoftware.com
Tue May 16 18:29:08 EDT 2006
hi there
I keep running into problems with my Address Book example. This one
should be simple but I can't find the problem. I may have spent too
much time looking at it. I get this error after I add an "entry" and
then try to edit it:
------
2006-05-16T17:09:39 ERROR SiteError http://localhost:8080/Jachin%
20Rupe/@@edit.html
Traceback (most recent call last):
File "/usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py",
line 138, in publish
result = publication.callObject(request, object)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/publication/
zopepublication.py", line 161, in callObject
return mapply(ob, request.getPositionalArguments(), request)
File "/usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py",
line 113, in mapply
return debug_call(object, args)
File "/usr/local/Zope-3.2.1/lib/python/zope/publisher/publish.py",
line 119, in debug_call
return object(*args)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/pagetemplate/
simpleviewclass.py", line 44, in __call__
return self.index(*args, **kw)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/pagetemplate/
viewpagetemplatefile.py", line 83, in __call__
return self.im_func(im_self, *args, **kw)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/pagetemplate/
viewpagetemplatefile.py", line 51, in __call__
sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
File "/usr/local/Zope-3.2.1/lib/python/zope/pagetemplate/
pagetemplate.py", line 117, in pt_render
strictinsert=0, sourceAnnotations=sourceAnnotations)()
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 277, in __call__
self.interpret(self.program)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 352, in interpret
handlers[opcode](self, args)
File "/usr/local/Zope-3.2.1/lib/python/zope/tal/
talinterpreter.py", line 871, in do_condition
if not self.tal or self.engine.evaluateBoolean(condition):
File "/usr/local/Zope-3.2.1/lib/python/zope/tales/tales.py", line
701, in evaluateBoolean
return not not self.evaluate(expr)
File "/usr/local/Zope-3.2.1/lib/python/zope/tales/tales.py", line
696, in evaluate
return expression(self)
File "/usr/local/Zope-3.2.1/lib/python/zope/tales/expressions.py",
line 205, in __call__
return self._eval(econtext)
File "/usr/local/Zope-3.2.1/lib/python/zope/tales/expressions.py",
line 199, in _eval
return ob()
File "/usr/local/Zope-3.2.1/lib/python/zope/app/form/browser/
editview.py", line 98, in update
target=content, names=self.fieldNames)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/form/utility.py",
line 303, in applyWidgetsChanges
changed = widget.applyChanges(target) or changed
File "/usr/local/Zope-3.2.1/lib/python/zope/app/form/browser/
objectwidget.py", line 162, in applyChanges
names=self.names)
File "/usr/local/Zope-3.2.1/lib/python/zope/app/form/utility.py",
line 303, in applyWidgetsChanges
changed = widget.applyChanges(target) or changed
File "/usr/local/Zope-3.2.1/lib/python/zope/app/form/__init__.py",
line 86, in applyChanges
field.set(content, value)
File "/usr/local/Zope-3.2.1/lib/python/zope/schema/
_bootstrapfields.py", line 183, in set
setattr(object, self.__name__, value)
ForbiddenAttribute: ('street', <simple_abook.entry.ABookEntry
instance at 0x3afa828>)
-----
No data seems to get saved in the street field when I use the addform
either.
I'll put the code I'm working with at the bottom.
I have been trying to get a good understanding of ObjectWidget and
have been have a really hard time. I got most of the code layout for
this from here: http://www.mail-archive.com/zope3-users@zope.org/
msg00917.html
I'm using Zope 3.2.1
It seems like since it's a security problem I should be able to fix
it by changing something in configuration.zcml but I just can not see
anything I'm missing. Any help would be appreciated.
thanks.
-jachin
----------------------
configure.zcml
----------------------
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">
<content class=".entry.StreetAddress">
<require
permission="zope.View"
interface=".interfaces.IStreetAddress"
/>
<require
permission="zope.ManageContent"
set_schema=".interfaces.IStreetAddress"
/>
</content>
<content class=".entry.ABookEntry">
<require
permission="zope.View"
interface=".interfaces.IABookEntry"
/>
<require
permission="zope.ManageContent"
set_schema=".interfaces.IABookEntry"
/>
</content>
<browser:editform
label="Change the entry data"
name="edit.html"
schema=".interfaces.IABookEntry"
class=".widget.ABookEntryEditView"
menu="zmi_views"
title="Edit"
permission="zope.ManageContent"
/>
<browser:addform
label="Add an entry"
name="AddEntry.html"
schema=".interfaces.IABookEntry"
class=".widget.ABookEntryEditView"
content_factory=".entry.ABookEntry"
permission="zope.ManageContent"
/>
<browser:addMenuItem
title="ABook Entry"
class=".entry.ABookEntry"
permission="zope.ManageContent"
view="AddEntry.html"
/>
</configure>
----------------------
interfaces.py
----------------------
from zope.interface import Interface
from zope.schema import TextLine, Int, Object
class IStreetAddress(Interface):
street = TextLine(
title=u"street",
description=u"",
required=False)
class IABookEntry(Interface):
streetAddress = Object(
schema=IStreetAddress,
title=u"Street Address",
description=u"",
required=False)
firstName = TextLine(
title=u"First Name",
description=u"",
required=False)
----------------------
entry.py
----------------------
from zope.interface import implements
from interfaces import IStreetAddress, IABookEntry
from zope.schema.fieldproperty import FieldProperty
class StreetAddress:
"""The Street Address object."""
implements(IStreetAddress)
class ABookEntry:
"""The Address Book Entry object."""
streetAddress = FieldProperty(IABookEntry['streetAddress'])
implements(IABookEntry)
----------------------
widget.py
----------------------
from zope.app.form.browser.editview import EditView
from zope.app.form import CustomWidgetFactory
from zope.app.form.browser import ObjectWidget
from interfaces import IABookEntry
from entry import StreetAddress, ABookEntry
class ABookEntryEditView(EditView):
__used_for__ = IABookEntry
streetAddress_widget = CustomWidgetFactory(ObjectWidget,
ABookEntry)
More information about the Zope3-users
mailing list