[Zope3-Users] stuck with zope.schema.Object
Roger Ineichen
dev at projekt01.ch
Thu Apr 14 15:10:19 EDT 2005
Hi Adam
> -----Original Message-----
> From: zope3-users-bounces at zope.org
> [mailto:zope3-users-bounces at zope.org] On Behalf Of Adam Groszer
> Sent: Thursday, April 14, 2005 7:29 PM
> To: zope3-users
> Subject: [Zope3-Users] stuck with zope.schema.Object
>
> I defined an interface like this:
>
> class IBejegyzes(Interface):
> <snip>
> sablon = Text(
> title=u"Sablon",
> required=True
> )
>
> implemented it:
>
> class Bejegyzes(BTreeContainer):
> implements(IBejegyzes, IBejegyzesContainer, IBejegyzesContained)
> <snip>
> sablon = FieldProperty(IBejegyzes['sablon'])
>
> configured it:
>
> <interface
> interface=".interfaces.IBejegyzes"
> type="zope.app.content.interfaces.IContentType"
> />
>
> <content class=".bejegyzes.Bejegyzes">
> <factory
> id="dkr.Bejegyzes"
> title="Uj bejegyzés készitése"
> description="This factory instantiates new Bejegyzes"
> />
> <implements
>
> interface="zope.app.annotation.interfaces.IAttributeAnnotatable
> zope.app.container.interfaces.IContentContainer"
> />
> <require
> permission="zope.View"
> interface=".interfaces.IBejegyzes"
> />
> <require
> permission="zope.ManageContent"
> interface=".interfaces.IBejegyzesContainer"
> />
> <require
> permission="zope.ManageContent"
> set_schema=".interfaces.IBejegyzes"
> />
> </content>
>
> <browser:addform
> label="Uj Bejegyzés"
> name="AddBejegyzes.html"
> schema="dkr.interfaces.IBejegyzes"
> content_factory="dkr.bejegyzes.Bejegyzes"
> permission="zope.ManageContent"
> set_before_add="code"
> />
>
> <browser:addMenuItem
> title="Bejegyzés"
> class="dkr.bejegyzes.Bejegyzes"
> permission="zope.ManageContent"
> view="AddBejegyzes.html"
> />
>
> it works fine. As soon as I change the interface to: (and delete
> data.fs and friends)
>
> class IBejegyzes(Interface):
> <snip>
> sablon = Object(
> schema=ISablon,
> title=u"Sablon",
> required=True
> )
>
> as I want to add a new object to it's container, the following
> exception comes:
>
> File "Y:\zope\svn_zope3\src\zope\component\__init__.py",
> line 154, in getMulti
> Adapter
> raise ComponentLookupError(objects, interface, name)
> ComponentLookupError: ((<zope.schema._field.Object object at
> 0x030F91F0>, <zope.
> publisher.browser.BrowserRequest instance
> URL=http://localhost:8080/2/@@+/action
> .html>), <InterfaceClass zope.app.form.interfaces.IInputWidget>, u'')
> 127.0.0.1 - zope.manager [14/Apr/2005:19:22:46 +0200] "GET
> /2/@@+/action.html?ty
> pe_name=AddBejegyzes.html HTTP/1.1" 500 311
> "http://localhost:8080/2/@@contents.
> html" "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;
> rv:1.7.6) Gecko/20050317
> Firefox/1.0.2"
>
> Do I missed something? What is the problem?
Yup, you have to define custom widgets with ObjectWidget
if you use Object fields.
I added a sample which explains it in the file:
zope.app.form.browser.objectwidget.txt
Regards
Roger Ineichen
Projekt01 GmbH
www.projekt01.ch
_____________________________
END OF MESSAGE
> --
> Best regards,
> Adam mailto:adamg at fw.hu
>
>
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
>
More information about the Zope3-users
mailing list