Re: [Zope3-Users] Interfaces in Schemas

2007-04-20 Thread Hermann Himmelbauer
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

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Interfaces in Schemas

2007-04-19 Thread Hermann Himmelbauer
Am Mittwoch, 18. April 2007 23:24 schrieb Darryl Cousins:
 Hi,

 On Wed, 2007-04-18 at 09:21 -0700, Martin Aspeli wrote:
  Hermann Himmelbauer wrote:
   Hi,
   I wonder if it's possible to define attributes in a schema that
   reference other interfaces. For instance, I have a schema for a car and
   another one for
   a wheel and what I want to do is something like that:
  
   class IWheel(Interface):
  type = TextLine()
  
   class ICar(Interface):
  
  model = TextLine()
  
  wheel = ??? of type IWheel ???
 
  wheel = schema.Object(schema=IWheel)
 
   or even better:
  wheel = List(min_length=4, max_length=4,
   value_type = ??? of type IWheel???)
 
  value_type=schema.Object(schema=IWheel)
 
   What would be really great now is if formlib could handle this and
   would automatically set up the needed widgets.
 
  Not sure what it does; I think you'd need to write some custom reference
  widget type thing; you can't fill in a wheel, really. :) Where would
  the Wheel objects come from?

 This tutorial will be enough to get you started with a custom widget for
 your List-Object field.

 http://zope3.mpg.de/cgi-bin/twiki/view/Zope/KomplexerContent

Ah, that's very nice, thanks!

 Tried it out and it seems to work for Objects() in the schema. However, for 
Lists(value_type=Object()), I get permission problems:

ForbiddenAttribute: ('__getitem__', [zbsp.fp.Email object at 0x31eed90])

This happens whenever I try to access the list in any way (e.g. mylist[0] or 
for i in mylist...). So it seems, I have to declare permissions for this 
list - but how? For the generic Python list object?

My permissions are declared like this:  

class class=.fp.MyObj
  require
  permission=zope.View
  interface=.interfaces.IMyObj
  /
  require
  permission=zope.ManageContent
  set_schema=.interfaces.IMyObj
  /
/class

I thought this would suffice?

Best Regards,
Hermann


Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Interfaces in Schemas

2007-04-19 Thread 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/

maybe useful.


Cheers, Sascha

-- 
Lalisio - connecting knowledge worldwide

Lalisio GmbH
Puschkinstraße 1
99084 Erfurt
fon +49 (0)361 541 43 80
fax +49 (0)361 541 43 79
[EMAIL PROTECTED]
www.lalisio.com

Sitz der Gesellschaft: Erfurt
Amtsgericht Jena, HRB 113943
Geschäftsführerin: Ute Rother
Ust-Id.: DE813237441
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Interfaces in Schemas

2007-04-19 Thread Christophe Combelles

There is also a Poll example somewhere in the ++apidoc++
which uses the Object schema field

Christophe

Sascha Ottolski a écrit :

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/

maybe useful.


Cheers, Sascha



___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Interfaces in Schemas

2007-04-18 Thread Hermann Himmelbauer
Hi,
I wonder if it's possible to define attributes in a schema that reference 
other interfaces. For instance, I have a schema for a car and another one for 
a wheel and what I want to do is something like that:

class IWheel(Interface):
   type = TextLine()

class ICar(Interface):

   model = TextLine()

   wheel = ??? of type IWheel ???

or even better:
   wheel = List(min_length=4, max_length=4, 
value_type = ??? of type IWheel???)

What would be really great now is if formlib could handle this and would 
automatically set up the needed widgets.

Is this possible in some way?

I found the field types Object and InterfaceField, maybe they are of this 
kind and do what I need?

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Interfaces in Schemas

2007-04-18 Thread Martin Aspeli



Hermann Himmelbauer wrote:
 
 Hi,
 I wonder if it's possible to define attributes in a schema that reference 
 other interfaces. For instance, I have a schema for a car and another one
 for 
 a wheel and what I want to do is something like that:
 
 class IWheel(Interface):
type = TextLine()
 
 class ICar(Interface):
 
model = TextLine()
 
wheel = ??? of type IWheel ???
 

wheel = schema.Object(schema=IWheel)



 or even better:
wheel = List(min_length=4, max_length=4, 
 value_type = ??? of type IWheel???)
 

value_type=schema.Object(schema=IWheel)



 What would be really great now is if formlib could handle this and would 
 automatically set up the needed widgets.
 

Not sure what it does; I think you'd need to write some custom reference
widget type thing; you can't fill in a wheel, really. :) Where would the
Wheel objects come from?

Martin
-- 
View this message in context: 
http://www.nabble.com/Interfaces-in-Schemas-tf3601683.html#a10061121
Sent from the Zope3 - users mailing list archive at Nabble.com.

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Interfaces in Schemas

2007-04-18 Thread Darryl Cousins
Hi,

On Wed, 2007-04-18 at 09:21 -0700, Martin Aspeli wrote:
 
 
 Hermann Himmelbauer wrote:
  
  Hi,
  I wonder if it's possible to define attributes in a schema that reference 
  other interfaces. For instance, I have a schema for a car and another one
  for 
  a wheel and what I want to do is something like that:
  
  class IWheel(Interface):
 type = TextLine()
  
  class ICar(Interface):
  
 model = TextLine()
  
 wheel = ??? of type IWheel ???
  
 
 wheel = schema.Object(schema=IWheel)
 
 
 
  or even better:
 wheel = List(min_length=4, max_length=4, 
  value_type = ??? of type IWheel???)
  
 
 value_type=schema.Object(schema=IWheel)
 
 
 
  What would be really great now is if formlib could handle this and would 
  automatically set up the needed widgets.
  
 
 Not sure what it does; I think you'd need to write some custom reference
 widget type thing; you can't fill in a wheel, really. :) Where would the
 Wheel objects come from?
 

This tutorial will be enough to get you started with a custom widget for
your List-Object field.

http://zope3.mpg.de/cgi-bin/twiki/view/Zope/KomplexerContent

Best regards,
Darryl

 Martin

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users