[Zope3-Users] WrongContainedType

Marius Gedminas marius at gedmin.as
Thu Oct 9 21:08:30 EDT 2008


On Thu, Oct 09, 2008 at 08:42:21AM -0300, Tim Cook wrote:
> I am having difficulty understanding this error.
> 
> It occurs in the call:
>  ontObj.parentArchetype = ObjectRef(oid,u'openehr',u'ARCHETYPE')
> 
> The first parameter for ObjectRef is declared in the schema as:
> 
>     refId = Object(
>         schema=IObjectId,
>         title = _(u'Id'),
>         description = _(u'Globally unique id of an object (of type
> ObjectId), regardless of where it is stored.'),
>         required = True
>         )
> 
> If I print the parameter 'oid' it does correctly report:
> <oship.openehr.rm.support.identification.objectid.ObjectId object at
> 0x1b70210>
> 
> the other two parameters for ObjectRef are declared as TextLines.
> 
> The traceback is:
> zope.schema.interfaces.WrongContainedType: [, []] 

Oh dear.  That's one of the worst error messages I've seen.

> What I do not understand is how to interpret the [, []] 

By reading the source code.

Object field validation actually attempts to validate the schema
(IObjectId in this case) of the object you're trying to store (the
ObjectId object, in this case).  If any of the fields cannot be
validated during this nested validation, you get a WrongContainedType
with the list of errors (one for each field).

Apparently those errors have horrible __repr__s.  That ought to be
fixed.

> I'm not passing a list nor is the schema using a list.
> 
> I realize that this may be pretty basic but I am missing something in
> reading the error.

I'd put a breakpoint in zope.schema._field, specifically, in
Object._validate, and try to see what's wrong by single-stepping.

Marius Gedminas
-- 
We're sysadmins. To us, data is a protocol-overhead.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20081009/d8b8d5a5/attachment.bin 


More information about the Zope3-users mailing list