[Zope3-Users] Using metadata and __name__ in addform
Florian Lindner
mailinglists at xgm.de
Mon May 16 11:31:58 EDT 2005
Am Donnerstag, 12. Mai 2005 15:52 schrieb Fred Drake:
> On 5/11/05, Florian Lindner <mailinglists at xgm.de> wrote:
> > factory = annotatableadapter.partialAnnotatableAdapterFactory(["title"])
> >
> > I'm not sure where to place this call (in the interface, in the
> > implementation, in which function, ...) and what to do with the factory
> > variable. Is there a real example for that? Besides the tests in
> > partial.txt.
>
> Here, "factory" is a new IZopeDublinCore factory. It should be
> registered as the adapter for the relevant content type via ZCML:
>
> <adapter
> for=".impl.MyContentClass"
> provides="zope.app.dublincore.interfaces.IZopeDublinCore"
> factory="impl.factory"
> />
>
> Does this help?
Hello,
I've implemented it now, but I get the following error when I try to change or
add a new ILink.
I'm logged in as zope.Manager.
My configure.zcml:
<adapter
for=".link.Link"
provides="zope.app.dublincore.interfaces.IZopeDublinCore"
factory=".link.factory"
/>
My link.py:
[...]
from zope.app.dublincore import annotatableadapter
factory = annotatableadapter.partialAnnotatableAdapterFactory(["description"])
the description field is defined in the interface:
description = TextLine (
title = u"Description",
description = u"Description which mirrors the DC metadata.",
required = False)
What is wrong there?
Thanks,
Florian
2005-05-16T17:26:57 ERROR SiteError
http://localhost:8080/cs/home/zope.manager/+/AddCSLink.html%3D
Traceback (most recent call last):
File "/home/florian/Zope3/src/zope/publisher/publish.py", line 138, in
publish
result = publication.callObject(request, object)
File "/home/florian/Zope3/src/zope/app/publication/zopepublication.py", line
164, in callObject
return mapply(ob, request.getPositionalArguments(), request)
File "/home/florian/Zope3/src/zope/publisher/publish.py", line 113, in
mapply
return debug_call(object, args)
File "/home/florian/Zope3/src/zope/publisher/publish.py", line 119, in
debug_call
return object(*args)
File "/home/florian/Zope3/src/zope/app/pagetemplate/simpleviewclass.py",
line 44, in __call__
return self.index(*args, **kw)
File
"/home/florian/Zope3/src/zope/app/pagetemplate/viewpagetemplatefile.py", line
83, in __call__
return self.im_func(im_self, *args, **kw)
File
"/home/florian/Zope3/src/zope/app/pagetemplate/viewpagetemplatefile.py", line
51, in __call__
sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
File "/home/florian/Zope3/src/zope/pagetemplate/pagetemplate.py", line 117,
in pt_render
strictinsert=0, sourceAnnotations=sourceAnnotations)()
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 234, in
__call__
self.interpret(self.program)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 309, in
interpret
handlers[opcode](self, args)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 806, in
do_useMacro
self.interpret(macro)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 309, in
interpret
handlers[opcode](self, args)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 497, in
do_optTag_tal
self.do_optTag(stuff)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 482, in
do_optTag
return self.no_tag(start, program)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 477, in
no_tag
self.interpret(program)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 309, in
interpret
handlers[opcode](self, args)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 776, in
do_defineMacro
self.interpret(macro)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 309, in
interpret
handlers[opcode](self, args)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 878, in
do_defineSlot
self.interpret(block)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 309, in
interpret
handlers[opcode](self, args)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 868, in
do_defineSlot
self.interpret(slot)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 309, in
interpret
handlers[opcode](self, args)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 776, in
do_defineMacro
self.interpret(macro)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 309, in
interpret
handlers[opcode](self, args)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 776, in
do_defineMacro
self.interpret(macro)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 309, in
interpret
handlers[opcode](self, args)
File "/home/florian/Zope3/src/zope/tal/talinterpreter.py", line 547, in
do_setLocal_tal
self.engine.setLocal(name, self.engine.evaluateValue(expr))
File "/home/florian/Zope3/src/zope/tales/tales.py", line 698, in evaluate
return expression(self)
File "/home/florian/Zope3/src/zope/tales/expressions.py", line 204, in
__call__
return self._eval(econtext)
File "/home/florian/Zope3/src/zope/tales/expressions.py", line 198, in _eval
return ob()
File "/home/florian/Zope3/src/zope/app/form/browser/add.py", line 59, in
update
self.createAndAdd(data)
File "/home/florian/Zope3/src/zope/app/form/browser/add.py", line 123, in
createAndAdd
notify(ObjectModifiedEvent(content))
File "/home/florian/Zope3/src/zope/event/__init__.py", line 23, in notify
subscriber(event)
File "/home/florian/Zope3/src/zope/app/event/dispatching.py", line 65, in
dispatch
for ignored in subscribers(event, None):
File "/home/florian/Zope3/src/zope/component/__init__.py", line 181, in
subscribers
return sitemanager.subscribers(objects, interface)
File "/home/florian/Zope3/src/zope/component/site.py", line 89, in
subscribers
return self.adapters.subscribers(required, provided)
File "/home/florian/Zope3/src/zope/interface/adapter.py", line 476, in
subscribers
return [subscription(*objects) for subscription in subscriptions]
File "/home/florian/Zope3/src/zope/app/dublincore/timeannotators.py", line
31, in ModifiedAnnotator
dc.modified = datetime.utcnow()
File "/home/florian/Zope3/src/zope/app/dublincore/zopedublincore.py", line
75, in __set__
super(DateProperty, self).__set__(inst, value)
File "/home/florian/Zope3/src/zope/app/dublincore/zopedublincore.py", line
48, in __set__
inst._changed()
File "/home/florian/Zope3/src/zope/app/dublincore/annotatableadapter.py",
line 49, in _changed
self.annotations[DCkey] = self._mapping
File "/home/florian/Zope3/src/zope/app/annotation/attribute.py", line 66, in
__setitem__
annotations = self.obj.__annotations__ = OOBTree()
ForbiddenAttribute: ('__annotations__', <CS.Link.link.Link object at
0xb2a1bd8c>)
127.0.0.1 - zope.manager [16/May/2005:17:26:57 +0200]
"POST /cs/home/zope.manager/+/AddCSLink.html%3D HTTP/1.1" 500 316
"http://localhost:8080/cs/home/zope.manager/+/AddCSLink.html=" "Mozilla/5.0
(compatible; Konqueror/3.4; Linux) KHTML/3.4.0 (like Gecko)"
More information about the Zope3-users
mailing list