[Grok-dev] 1.0 Bugs

Tim Cook timothywayne.cook at gmail.com
Thu Dec 11 03:19:53 EST 2008


On Thu, 2008-12-11 at 08:20 +0100, Todd wrote:
> Hi Tim,
> 
> I suppose the best step to take right now is describe the bug on this 
> list so other developers can decide to make an 'issue' out of it.


Thanks Todd.



When a schema contains a reference via the Object field type to another
schema that contains another reference to a schema via the Object field
type the _validate_fields function incorrectly causes and exception at
line 467 in _field.py

As discussed in this thread on the mailing list.
http://mail.zope.org/pipermail/zope3-users/2008-October/008215.html

This seems to be because if errors is None it is assigned as an empty
list. When the second call is made it appears to append another empty
list to the outer one. Therefore the outer list is no longer empty and
raises the exception.

This is a show stopper for my project where we have dozens of these
chains.

My solution that seems to still catch a valid exception and not fail
incorrectly is to change the _validate_fields function to the code
below. However, I do not know if there are other ramifications with the
ZCA.

def _validate_fields(schema, value, errors=None):
    if errors is not None:
        #errors = []
        for name in schema.names(all=True):
            if not IMethod.providedBy(schema[name]):
                try:
                    attribute = schema[name]
                    if IField.providedBy(attribute):
                        # validate attributes that are fields
                        attribute.validate(getattr(value, name))
                except ValidationError, error:
                    errors.append(error)
                except AttributeError, error:
                    # property for the given name is not implemented
                    errors.append(SchemaNotFullyImplemented(error))
    return errors




-- 
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/grok-dev/attachments/20081211/620e8c3c/attachment.bin 


More information about the Grok-dev mailing list