Tuesday, August 19, 2008

A mysterious error solved (TypeError: expected string or buffer)

Today, I ran into an error message when creating a new object. The object was going to be an instance of "ImportedObject", which i created with ArchGenXML. Here is the traceback:

2008-08-19 11:51:27 ERROR Plone
Traceback (most recent call last):
File "/opt/zope/prd/www.domain.com/Products/CMFPlone/FactoryTool.py", line 147, in __getitem__
File "/opt/zope/prd/www.domain.com/Products/CMFPlone/PloneFolder.py", line 399, in invokeFactory
File "/opt/zope/prd/www.domain.com/Products/CMFCore/TypesTool.py", line 934, in constructContent
File "/opt/zope/prd/www.domain.com/Products/CMFCore/TypesTool.py", line 343, in constructInstance
File "/opt/zope/prd/www.domain.com/Products/CMFCore/TypesTool.py", line 574, in _constructInstance
File "", line 4, in addImportedProject
File "/home/kees/zope-2.9.9/lib/python/OFS/ObjectManager.py", line 333, in _setObject
notify(ObjectAddedEvent(ob, self, id))
File "/home/kees/zope-2.9.9/lib/python/zope/event/__init__.py", line 23, in notify
subscriber(event)
File "/home/kees/zope-2.9.9/lib/python/zope/app/event/dispatching.py", line 66, in dispatch
for ignored in subscribers(event, None):
File "/home/kees/zope-2.9.9/lib/python/zope/component/__init__.py", line 181, in subscribers
return sitemanager.subscribers(objects, interface)
File "/home/kees/zope-2.9.9/lib/python/zope/component/site.py", line 89, in subscribers
return self.adapters.subscribers(required, provided)
File "/home/kees/zope-2.9.9/lib/python/zope/interface/adapter.py", line 481, in subscribers
subscribers = [subscription(*objects)
File "/home/kees/zope-2.9.9/lib/python/zope/app/event/objectevent.py", line 192, in objectEventNotify
adapters = subscribers((event.object, event), None)
File "/home/kees/zope-2.9.9/lib/python/zope/component/__init__.py", line 181, in subscribers
return sitemanager.subscribers(objects, interface)
File "/home/kees/zope-2.9.9/lib/python/zope/component/site.py", line 89, in subscribers
return self.adapters.subscribers(required, provided)
File "/home/kees/zope-2.9.9/lib/python/zope/interface/adapter.py", line 481, in subscribers
subscribers = [subscription(*objects)
File "/home/kees/zope-2.9.9/lib/python/OFS/subscribers.py", line 114, in dispatchObjectMovedEvent
callManageAfterAdd(ob, event.object, event.newParent)
File "/home/kees/zope-2.9.9/lib/python/OFS/subscribers.py", line 144, in callManageAfterAdd
ob.manage_afterAdd(item, container)
File "/opt/zope/prd/www.domain.com/Products/Archetypes/BaseFolder.py", line 88, in manage_afterAdd
File "/opt/zope/prd/www.domain.com/Products/CMFCore/CMFCatalogAware.py", line 202, in manage_afterAdd
File "/opt/zope/prd/www.domain.com/Products/Archetypes/CatalogMultiplex.py", line 34, in indexObject
File "/opt/zope/prd/www.domain.com/Products/I18NFolder/patches.py", line 281, in catalog_object
File "/opt/zope/prd/noorderlink/client0/Products/CacheSetup/patch.py", line 100, in catalog_object
File "/opt/zope/prd/noorderlink/client0/Products/CacheSetup/patch_utils.py", line 6, in call
File "/home/kees/zope-2.9.9/lib/python/Products/ZCatalog/ZCatalog.py", line 567, in catalog_object
update_metadata=update_metadata)
File "/home/kees/zope-2.9.9/lib/python/Products/ZCatalog/Catalog.py", line 339, in catalogObject
index = self.updateMetadata(object, uid)
File "/home/kees/zope-2.9.9/lib/python/Products/ZCatalog/Catalog.py", line 277, in updateMetadata
newDataRecord = self.recordify(object)
File "/home/kees/zope-2.9.9/lib/python/Products/ZCatalog/Catalog.py", line 416, in recordify
attr=getattr(object, x, MV)
File "/opt/zope/prd/www.domain.com/Products/CMFPlone/CatalogTool.py", line 99, in __getattr__
File "/opt/zope/prd/www.domain.com/Products/CMFPlone/CatalogTool.py", line 206, in getObjSize
File "/opt/zope/prd/www.domain.com/Products/Archetypes/BaseObject.py", line 583, in get_size
File "/opt/zope/prd/www.domain.com/Products/Archetypes/Field.py", line 1311, in get_size
File "/opt/zope/prd/www.domain.com/Products/Archetypes/Field.py", line 1305, in getBaseUnit
File "/opt/zope/prd/www.domain.com/Products/Archetypes/Field.py", line 1278, in get
File "/opt/zope/prd/www.domain.com/Products/Archetypes/Field.py", line 1033, in _wrapValue
File "/opt/zope/prd/www.domain.com/Products/Archetypes/Field.py", line 1168, in _make_file
File "/opt/zope/prd/www.domain.com/Products/Archetypes/BaseUnit.py", line 34, in __init__
File "/opt/zope/prd/www.domain.com/Products/Archetypes/BaseUnit.py", line 56, in update
File "/opt/zope/prd/www.domain.com/Products/MimetypesRegistry/MimeTypesRegistry.py", line 370, in __call__
File "/opt/zope/prd/www.domain.com/Products/MimetypesRegistry/MimeTypesRegistry.py", line 319, in classify
File "/opt/zope/prd/www.domain.com/Products/MimetypesRegistry/mime_types/mtr_mimetypes.py", line 82, in classify
File "/usr/lib/python2.4/sre.py", line 134, in search
return _compile(pattern, flags).search(string)
TypeError: expected string or buffer

When i renamed the field 'update' on this class to 'myUpdate', it works fine. So clearly 'update' is a name to avoid for your fields. It would be interesting to keep a list somewhere of all unwise choices for field names.

No comments: