[Product-Developers] POSKeyError when indexing using External Method

Neil Stokes mrneil1964 at yahoo.com
Sat Feb 27 14:16:48 UTC 2010

I have an external method that exposes the last editor attribute of all
objects in the site.  Code is as follows:

def last_editor(self):
    """Return the last editor of an object."""

    if jar is None or oid is None: return None
    return result

I include a method in the __init.py__ file for my product to invoke this

def _lastEditor(obj,portal,vars):
    """A method to return the last editor attribute for Folders and
    if obj.getTypeInfo().getId() != 'ArchiveImage' and
obj.getTypeInfo().getId() != 'Folder':
        raise AttributeError
        return obj.last_editor

I register the indexable attribute


I go to ZMI, go to the catalog and create a Field Index with the attribute
'getLastEditor'.  When I check the checkbox and reindex, it works just fine. 
The index is updated, I can browse it and the correct items are there in the

If I now go back to my site and create a new object of one of the indexable
classes (Folder or my own object class ArchiveImage) I get a POSKeyError. 
This only occurs when adding an indexable object...I can add objects of
other classes with no problem.

If I delete the index, I can then add items of those classes again, so it
seems there is a problem whereby the zope does not know how to update the
index.  I suspect that zope is attempting to update the index before
committing the new object to the database, and that causes the error since
the OID is not found.

I've searched everywhere to determine what steps I'm missing or what I'm
doing wrong.  Any suggestions would be greatly appreciated.

Many thanks in advance,

View this message in context: http://n2.nabble.com/POSKeyError-when-indexing-using-External-Method-tp4645076p4645076.html
Sent from the Product Developers mailing list archive at Nabble.com.

More information about the Product-Developers mailing list