[Zope3-Users] Interfaces in Schemas
Hermann Himmelbauer
dusty at qwer.tk
Fri Apr 20 07:04:48 EDT 2007
Am Donnerstag, 19. April 2007 17:06 schrieb Sascha Ottolski:
> Am Donnerstag 19 April 2007 schrieb Hermann Himmelbauer:
> > Tried it out and it seems to work for Objects() in the schema.
> > However, for Lists(value_type=Object()), I get permission problems:
>
> not a real answer, but another hint:
>
> http://zope3demos.googlecode.com/svn/trunk/otherdemos/objectsofobjects2/
Ah, that's nice and easy. Did not solve the permission problems, though. I
found out that the list object, which I defined the Lists() schema for, is
not a python list, instead it's a sqlalchemy.orm.attributes.InstrumentedList.
Therefore it seems I have to set the permissions on this object, tried it
like that:
<class class="sqlalchemy.orm.attributes.InstrumentedList">
<require
permission="zope.View"
attributes="__iter__ __getitem__"
/>
</class>
The permission problems are gone now, but I have still some object nesting
problems with formlib. Here's what I have:
I have an object "Kunde", which 1:1 relates to a "Fp" object. That Fp object
relates 1:n to an "Email" object. I defined interfaces for all of these
objects and configured them. The browser code looks now like this:
fp_widget =CustomWidgetFactory(ObjectWidget,Fp)
email_widget = CustomWidgetFactory(ObjectWidget,Email)
emails_widget = CustomWidgetFactory(ListSequenceWidget,
subwidget=email_widget)
class EditKunde(form.Form):
form_fields = form.Fields(IKunde)
form_fields['fp'].custom_widget = fp_widget
# so far, this works, the Fp object is displayed.
# Now I need to apply the custom widget to the fp.emails list object
form_fields['fp'].emails.custom_widget = emails_widget
# Hmmm, this has no effect, I receive a ComponentLookupError:
ComponentLookupError: ((<zope.schema._field.Object object at 0x31e9910>,
<zc.resourcelibrary.publication.Request instance
URL=http://localhost:8080/act/managekunde/index.html>), <InterfaceClass
zope.app.form.interfaces.IInputWidget>, u'')
Moreover it would be nice if I could omit some attributes of the sub-objects -
do you know if there's some way to do that? E.g. something
like "form_fields.omit('fp.xyz')", or even more something
like "form_fields.omit('fp.emails.xyz')?
Best Regards,
Hermann
--
x1 at aon.at
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7
More information about the Zope3-users
mailing list