Object creation breaks at random when a title for the "title" field is created

Bug #143755 reported by Joao S. O. Bueno Calligaris
2
Affects Status Importance Assigned to Milestone
Zope 2
Fix Released
Low
Unassigned

Bug Description

I created a FieldIndex for the 'title' field in the zope zmi.
After that, when creating some Archetype objects that inherit straight from BaseContent, I'd get an exception. If the "title" field would be hidden it would work.

Debugging it, I found out that the widget object itself is called without parameters in the UnIndex._get_object_datum method, in the file lib/python/Products/PluginIndexes/common/UnIndex.py

It happens that the "__call__" method for the StringWidget holding title expects 3 parameters (instead of one), once the title field is indexed. (I could not find why, not even can imagine what a call to a widget object should return if it worked at all).

This call is already inside a try-except clause that passes on "AttributeError".
The exception can be bypassed it the same try clause also passes "TypeError". I did this, and my app is working.

Therefore I am proposing this fix fo zope.

Tags: bugday
Revision history for this message
Joao S. O. Bueno Calligaris (gwidion) wrote :
Revision history for this message
Florent Guillaume (efge) wrote :

How exactly is this a Zope problem?

It seems to me that if Plone has a catalog index for a field 'title' that isn't a simple attribute or a callable with no arguments, then it's Plone's fault.

Revision history for this message
Joao S. O. Bueno Calligaris (gwidion) wrote :

I mean,
just take a look at the method in question. It just make for some half-blind attribute digging, and the prove for it is that it is already enclosed in a try-except clause. What happens is that I fell in an exception that was not covered by the original except clause, and needed one more . The code there is just meant to fault if it finds things it dislikes, and then it should just ignore it, not become a show stopper.

As for being a zope problem: I just created an Index,a plain zope FierdIndex through the zmi, and things went crashing. The crash was in zope code. AFAIK it could have happened with any other object/Index combination.

Revision history for this message
Andreas Jung (ajung) wrote :

Status: Pending => Rejected

The related code is not designed to deal with any kind of errors that are caused by errors on the application side. Potentially there could be other exceptions as well..we don't want to deal with them..the application and the developer should know if there is an error caused by bad code.

Revision history for this message
Florent Guillaume (efge) wrote :

Status: Rejected => Pending

On the other hand, just because some object happens to have a method whose name corresponds to an indexed attribute (but is actually unrelated to the catalog) with different calling conventions, shouldn't make the catalog crash. It should be more robust.

So on second though, +1 on the patch.

Revision history for this message
Florent Guillaume (efge) wrote :

Of course this won't be applied without a unit test.
And btw a simple patch would just change AttributeError into (AttributeError, TypeError).

Tres Seaver (tseaver)
Changed in zope2:
importance: Medium → Low
status: New → Triaged
tags: added: bugday
removed: bug+solution zope
Revision history for this message
Jens Vagelpohl (dataflake-deactivatedaccount-deactivatedaccount) wrote :

Applied the fix and added a simple test:

Zope 2.12 branch: http://svn.zope.org/?rev=114746&view=rev

Zope trunk: http://svn.zope.org/?rev=114747&view=rev

Changed in zope2:
status: Triaged → Fix Committed
assignee: nobody → Jens Vagelpohl (dataflake)
milestone: none → 2.12.10
Changed in zope2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.