[Zope3-dev] Re: __name__ in auto generated addforms
Florian Lindner
mailinglists at xgm.de
Mon May 23 16:02:34 EDT 2005
Am Sonntag, 22. Mai 2005 01:31 schrieb Ruslan Spivak:
> В Сбт, 21/05/2005 в 19:33 +0200, Florian Lindner пишет:
> > Hello,
> > is it possible to let the user enter the name of a object (the __name__
> > attribut) in forms that are auto generated from schema data (via the
> > addform directive)?
> >
> > Thanks,
> >
> > Florian
>
> Hi, Florian.
>
> You need create adapter to zope.app.container.interfaces.INameChooser
> and register it for your xxx interface.
>
> Take a look at bugtracker application inside zope, it contains example
> of INameChooser usage.
Ok, I've done so.
I've created a INameChooser implementation:
from zope.app.container.interfaces import INameChooser
class NameChooser:
implements(INameChooser)
def __init__(self, context):
self.context = context
def chooseName(self, name, object):
print object
return object.title
gives the traceback:
2005-05-23T22:01:13 ERROR SiteError
http://localhost:8080/cs/home/zope.manager/t
estfolder/+/AddCSLink.html%3D
Traceback (most recent call last):
File
"/home/florian/Desktop/zope/lib/python/CS/ContentFolder/contentfolder.py" ,
line 22, in chooseName
return object.title
AttributeError: 'Link' object has no attribute 'title'
but the Link object has a attribute title.
title = TextLine(
title = u"Title",
description = u"Short title",
required = True
)
What is wrong there?
Thanks,
Florian
More information about the Zope3-dev
mailing list