Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Dev

zope.formlib does not correctly validate invariants with fields from a base interface

 

 

Zope dev RSS feed   Index | Next | Previous | View Threaded


sw at gocept

Jun 2, 2009, 5:05 AM

Post #1 of 2 (312 views)
Permalink
zope.formlib does not correctly validate invariants with fields from a base interface

Hi,

I'd like to fix the following bug: https://bugs.launchpad.net/zope2/+bug/382717

Example:

>>> import zope.interface
>>> import zope.schema

>>> class IBase(zope.interface.Interface):
... title = zope.schema.TextLine(
... title=u"Title",
... required=False)

>>> class ISub(IBase):
... sub_title = zope.schema.TextLine(
... title=u"Subtitle",
... required=False)
...
... @zope.interface.invariant
... def title_or_subtitle(obj):
... if not (obj.title or obj.sub_title):
... raise zope.interface.Invalid(
... u"Set either title or subtitle.")

When validating an object (using zope.formlib.form.checkInvariants),
which implements ISub, it's not possible to access the title attribute
inside the "title_or_subtitle" invariant checker method. It's
explicitly filtered out, which means, that only those schema
attributes, defined on the ISub interface, are available.

Is there any reason for this behavior? There is no test for this
behavior.

Suggestion:

If there is no specific reason for this behavior, the invariant should
get all the form field data from the request.

Best regards,

--
Sebastian Wehrmann · sw[at]gocept.com
gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 12 · fax +49 345 1229889 1
Zope and Plone consulting and development
Attachments: smime.p7s (2.37 KB)


sw at gocept

Jun 2, 2009, 6:42 AM

Post #2 of 2 (274 views)
Permalink
Re: zope.formlib does not correctly validate invariants with fields from a base interface [In reply to]

Hi again,

On Jun 2, 2009, at 14:05, Sebastian Wehrmann wrote:
> I'd like to fix the following bug: https://bugs.launchpad.net/zope2/+bug/382717

Sorry for the noise. This bug was already fixed in zope.formlib 3.4.0
r69738 by srichter. Unfortunately, Zope 2.10 uses an older version. In
Zope 2.11, the bug is fixed.

Best regards,
--
Sebastian Wehrmann · sw[at]gocept.com
gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 12 · fax +49 345 1229889 1
Zope and Plone consulting and development
Attachments: smime.p7s (2.37 KB)

Zope dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.