[Zope3-Users] [Zope-dev] Next Step to Bug Resolution???

Tim Cook timothywayne.cook at gmail.com
Fri Jan 16 16:06:58 EST 2009


Hi Shane,

On Tue, 2009-01-13 at 14:10 -0700, Shane Hathaway wrote:

> Sorry, but the patch doesn't make any sense.  Your version of 
> _validate_fields quietly skips validation entirely by default. 

First of all that is why I asked for others to look at it.  :-)
But I DID test it by inserting an incorrect schema and it did throw the
correct error. I think it was the ShemaNotImplemented error. This was a
few weeks ago but I can repeat it if needed. 

As I explained before; when one schema is checked by _validate_fields
then all is well. The parameter 'errors' is None.  Then errors is set to
an empty list and any possible error msgs are appended. BUT  when a
schema has to check another schema because they are chained.  'errors'
is already an empty list but even though the parameter errors is None a
new list is appended to the first pass errors.  This creates the msg
WrongContainedType: [, []] because it IS a WrongContainedType because
there is an empty list inside the original list.  

'errors' is returned from _validate_fields back to the _validate method
of the Object class where it is simply tested to see if it is empty.  On
this second pass it ISN't empty.  It has another list inside so it fails
the truth test and incorrectly throws an error.       


> Look at the __repr__ method of the ValidationError class in the 
> _bootstrapinterfaces.py module of the zope.schema package.  This method 
> was designed to generate short error messages, but in your case it 
> appears to be truncating the error messages altogether.  I would start 
> by changing that particular __repr__() method to:
> 
>      def __repr__(self):
>          return '%s(%s)' % (self.__class__.__name__, repr(self.args))
> 
> This version prefers verbosity.  At a minimum, I hope this version of 
> __repr__ will change the bizarre message 
> "zope.schema.interfaces.WrongContainedType: [, []]" into something legible.


It is more verbose.  But I'm afraid it exhibits the same behavior as
described above.  Here are the results:


in _validate
    raise WrongContainedType(errors)
WrongContainedType: [RequiredMissing(()),
WrongContainedType(([RequiredMissing(())],))]

Note the empty parens.  

Now if I introduce bad code I  get:
in _validate
    raise WrongContainedType(errors)
WrongContainedType: [RequiredMissing(()), SchemaNotProvided(())]

SchemaNotProvided is correct.  Though there isn't much else to go on but
the full traceback points me to the right place.

***************************************************************


Shane,

I think that so much of this is no longer useful.

Right not now I'll go back and read all the obscure documentation (for
the upteenth time) and see if it makes more sense now.

I am very confused about thee use cases between creating Fields and
using the Object(schema=Ischema) approach.

Thanks for your help.

--Tim









-- 
Timothy Cook, MSc
Health Informatics Research & Development Services
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook 
Skype ID == timothy.cook 
**************************************************************
*You may get my Public GPG key from  popular keyservers or   *
*from this link http://timothywayne.cook.googlepages.com/home*
**************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20090116/fd33b257/attachment.bin 


More information about the Zope3-users mailing list