AttributeError: _length
This Error Reference applies to:
Plone 2.1.x, Plone 2.0.x
This Error Reference is intended for:
Any audience.
Note from the editor: This fix is included in the migration mechanism in the Plone 2.1.1 release and newer. So this should only happen if you are upgrading to the exact 2.1.0 release while upgrading your Zope from 2.7 to 2.8 at the same time.
I got this error message when moving Plone 2.1 from Zope 2.7.5 (Debian / Sarge) and 2.7.9 (FreeBSD) to Zope 2.8.1, but the same problems can be result of upgrading also Plone 2.0.5 to Plone 2.1 along with zope upgrade.
When you get this error after upgrade try the following steps to make successfull upgrade:
- install Zope 2.8.1 and Plone 2.1
- copy the Data.fs from your 2.7.x instance
- start new Zope
- go to the ZMI
- open portal_catalog inside your Plone instance
- you will get an "AttributeError, _length
- call the "manage_convertIndexes" method of the ZCatalog (by replacing the "manage_main" part of the URL with "manage_convertIndexes") - the URL should look something like this:
http://localhost:8080/plonesite/portal_catalog/manage_convertIndexes - depending on the size of your ZCatalog the migration may take a while
- After the conversion a message will appear: "Indexes converted and reindexed".
- create new Python Script in
portal_skins/customfolder withid(fix_catalogor whatever) and replace it's sample code with the following code:return len(context.portal_catalog)
- save the script and click on
Testtab in the top of page- You'll see a number appear, that's the number of items in your catalog. At the same time, your catalog length attrtibute will have been converted,
- go back to portal_catalog and click on
Update Catalogbutton which can be found onAdvancedtab - open
uid_catalogand click onUpdate Catalogbutton which is also onAdvancedtab - return back to fixing script
fix_catalogand change the line of code to the following:return len(context.reference_catalog)
- save the script and click on
Testtab in the top of page- You'll see a number appear, that's the number of references in reference catalog. At the same time, your catalog length attrtibute will have been converted,
- open
reference_catalogand updated by the same way as in previous catalogs updates
Thanx for help here:
Forcing a 2.7 to 2.8 catalog upgrade
from Products.CMFPlone.migrations.v2_1.alphas import migrateCatalogIndexes
import transaction
if __name__ == '__main__':
portal = app.Plone
out = []
migrateCatalogIndexes(portal, out)
for line in out:
print line
transaction.get().commit()
Stop zope and then do a ./bin/zopectl run convert_indexes.py
Change the id of your plone site to fit.