[ZCM] [ZC] 753/ 4 Assign "inconsistencies in the way to detect a missing attribute"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Tue Apr 12 03:59:14 EDT 2005


Issue #753 Update (Assign) "inconsistencies in the way to detect a missing attribute"
 Status Pending, Catalog/bug medium
To followup, visit:
  http://www.zope.org/Collectors/Zope/753

==============================================================
= Assign - Entry #4 by htrd on Apr 12, 2005 3:59 am

 Status: Accepted => Pending

 Supporters removed: htrd

Unassigning myself.... Im going to have to leave this for someone else.
________________________________________
= Comment - Entry #3 by Caseman on Jan 2, 2003 10:35 am

I agree. So this means the behavior should be that:

* If an attribute error is raised by a callable attribute during indexing, the object will be
  discarded and the error trapped (Perhaps with a blather log entry). This should hold true for
  indexes and metadata.

* Objects that are missing an attribute should not be in indexes for that attribute. Doing so is
  a waste of resources not to mention inconsistent.

These rules should be documented in the ZCatalog and PlugInIndex interfaces.


________________________________________
= Assign - Entry #2 by htrd on Jan 2, 2003 6:58 am

 Status: Pending => Accepted

 Supporters added: htrd

> 1) metadata (see recordify in Catalog.py) uses MV from Missing to
>   indicate a missing attribute
> 
> 2) UnIndex (and all indexes derived from it) uses an private attribute
>   _marker defined as []

For both of these two you are describing implementation details that you dont need to know to be able to achieve what you want. Just raise an AttributeError and it *should* just work.

It looks like metadata (see recordify in Catalog.py) wont handle an AttributeError inside an accessor method. I think *this* is a bug.
 
> 3) KeywordIndex uses () as a missing attribute and just catalogs everything

Yes. KeywordIndex has switched this behaviour several times in its history, and I agree that the current behaviour is wrong. I believe an AttributeError 'should' cause the object to not appear in the index, rather than be indexed with no properties.


________________________________________
= Request - Entry #1 by olivluca on Jan 2, 2003 6:35 am

When catalogging/metadataing objects the catalog and plugin indexes try to detect a missing attribute in order to avoid indexing or storing metadata for a non existing attribute.
The problem is that each plugin index and the metadata extraction use different methods:

1) metadata (see recordify in Catalog.py) uses MV from Missing to indicate a missing attribute

2) UnIndex (and all indexes derived from it) uses an private attribute _marker defined as []

3) KeywordIndex uses () as a missing attribute and just catalogs everything


The problem is that if the attribute is provided by (e.g.) a python script, it's impossible for the python script to indicate a missing attribute, or it has to be done in several different methods:

a) for metadata is possible to return MV from Missing to indicate a missing attribute

b) for indexes deriving from UnIndex is impossible to indicate a missing attribute (since _marker is private)

c) for keyword indexes one has to return ()

d) even if it was possible to import the private _merker, it's not the same _marker for each index.

I think the solution would be to use the same value everywhere to detect a missing attribute, and this value should be useable from external method, like, e.g., MV from Missing, or a non private attribute imported from the same module.


==============================================================



More information about the Zope-Collector-Monitor mailing list