[Zope3-Users] WrongContainedType
Marius Gedminas
marius at gedmin.as
Fri Oct 10 13:28:49 EDT 2008
On Fri, Oct 10, 2008 at 06:19:48PM +0200, Roger Ineichen wrote:
> Hi Tim
>
> > Betreff: Re: AW: [Zope3-Users] WrongContainedType
> >
> > On Fri, 2008-10-10 at 17:46 +0200, Roger Ineichen wrote:
> >
> > > I guess not, normaly such an error has an empty
> > representation and the
> > > list is not empty. Try to do errors[0] or type(errors[0]) and you
> > > probably see something.
> > >
> > > If not I'm confused
> >
> > Well, I'm confused anyway, but that isn't difficult. ;-)
> >
> > After commenting the the if test on errors and the raise.
> >
> > With print 'Object schema validation errors=',type(errors[0]):
> > I get:
> > Object schema validation errors=
> > <class'zope.schema._bootstrapinterfaces.RequiredMissing'>
> > Object schema validation errors=
> > <class'zope.schema._bootstrapinterfaces.RequiredMissing'>
> >
> > With print 'Object schema validation errors=',errors[0]:
> > I get:
> > just the string Object schema validation errors= printed on each line.
> >
> > With print 'Object schema validation errors=',errors:
> > I get:
> > Object schema validation errors= []
> > Object schema validation errors= []
That's because RequiredMissing subclasses ValidationError, which defines
def __repr__(self):
return ' '.join(map(str, self.args))
That's bad code! No cookie! If you do
print [RequiredMissing()]
you will see
[]
which is not distinguishable from an empty list.
Things to fix:
* ValidationError's __repr__ should consider the corner case when
self.args is empty and return, say, self.__doc__.
* the piece of code that raises RequiredMissing should always supply
some arguments (at the very least, the name of the field with the
missing value)
> The error (probably, not sure) means that the object you
> like to store has a missing value. Can you check the
> schema of this object and set required=False in all fields?
>
> If there is a problem, can you post the interface and class
> of this object as a sample? And probably the code which
> tries to store the object.
That is the correct path to fixing Tim's problem, but I think we should
fix Zope as well.
Marius Gedminas
--
I used to be an agnostic, but now I'm not so sure.
-------------- 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/20081010/93174360/attachment.bin
More information about the Zope3-users
mailing list