Error when editing page

Here is the error when I try to edit a page (clicked edit on a page, even without making any changes clicked save). It is very cryptic to me. Any idea what it means?

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module plone.z3cform.layout, line 66, in __call__
  Module plone.z3cform.layout, line 50, in update
  Module plone.dexterity.browser.edit, line 58, in update
  Module plone.z3cform.fieldsets.extensible, line 59, in update
  Module plone.z3cform.patch, line 30, in GroupForm_update
  Module z3c.form.group, line 145, in update
  Module plone.app.z3cform.csrf, line 21, in execute
  Module z3c.form.action, line 98, in execute
  Module z3c.form.button, line 315, in __call__
  Module z3c.form.button, line 170, in __call__
  Module plone.dexterity.browser.edit, line 30, in handleApply
  Module z3c.form.group, line 126, in applyChanges
  Module zope.event, line 31, in notify
  Module zope.component.event, line 24, in dispatch
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module zope.component.event, line 32, in objectEventNotify
  Module zope.component._api, line 136, in subscribers
  Module zope.component.registry, line 321, in subscribers
  Module zope.interface.adapter, line 585, in subscribers
  Module plone.dexterity.content, line 774, in reindexOnModify
  Module Products.CMFCore.CMFCatalogAware, line 88, in reindexObject
  Module Products.CMFCore.CatalogTool, line 301, in reindexObject
  Module Products.CMFPlone.CatalogTool, line 351, in catalog_object
  Module Products.ZCatalog.ZCatalog, line 476, in catalog_object
  Module Products.ZCatalog.Catalog, line 360, in catalogObject
  Module Products.ZCTextIndex.ZCTextIndex, line 180, in index_object
  Module plone.indexer.wrapper, line 63, in __getattr__
  Module plone.indexer.delegate, line 20, in __call__
  Module plone.app.contenttypes.indexers, line 72, in SearchableText_document
  Module plone.app.contenttypes.indexers, line 53, in SearchableText
TypeError: 'unicode' object is not callable

Which version of plone.app.contenttypes is this?
How to reproduce?

-aj

Version Overview
Plone 5.0.8 (5018)
CMF 2.2.10
Zope 2.13.26
Python 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
PIL 3.3.0 (Pillow)

Content-types (plone.app.contenttypes) 1.2.17

Very easy to reproduce (in my instance at least)... click on a page that is not published. Click edit, make changes/or not, then click save.

Can not find a call to unicode here

Please re-verify.

That's what it said in the quickinstaller. 1.2.17
There was a 1.2.23 available so I upgraded it. Tried to edit the page. Same result.

I think I found the issue.

obj.Subject() should actually be obj.Subject

That is without parentheses. Subject is actually a string.

TESTED: yes, that was it.

err, no. If you actually changed the Plone code like this, it can't be correct. Subject is really a tuple. If in this case it is a string, it is a problem elsewhere. For the record this is working fine on a vanilla 5.08 version. Rather than changing the code like that, try to add something like:

print(obj)
print(obj.__class__)
print(obj.id)

just before subject=
and rerun Plone in debug mode (fg) to understand what is happening here to see what is displayed immediately before the trace.

I'll try that, thank you.

small typo in my post, Subject() is (of course) a method returning a tuple. This is clear from the code. So something is wrong in your install. Is it the result of migration ? is there add-ons ?

Nothin that I can point to. However, I am pulling data from an older plone instance and putting it in this one. I have to take a better look at my code to see how subject is special.

that should explain it then. It's very easy to put a string instead of an object in the Zodb and it can appear to work. However it will bites you at some time or another. The subject may seem just a text field where a string with carriage returns inside will fit, but it's not.

1 Like

So now that I change subject to a tuple the same line in indexers.py returns: TypeError: 'tuple' object is not callable.

Help :frowning:

I said that it's not a string, I did not say it was a tuple, it is an object that is managing several lines.

>>> plone=app.Plone
>>> from zope.component.hooks import setSite
>>> setSite(plone)
>>> from plone import api
>>> 
>>> with api.env.adopt_user(username="admin"):
...      documents = api.content.find(context=plone)
... 
>>> [d.getPath() for d in documents]
['/Plone/test/essai2', '/Plone/events/bbbbbbbbbbbbb', '/Plone/events/aaaaaaaaa', '/Plone/news/new-2', '/Plone/news/new-0', '/Plone/test/doc2test', '/Plone/test/test-glossary', '/Plone/news/new-1', '/Plone/upload1', '/Plone/upload2', '/Plone/test/essai', '/Plone/front-page', '/Plone/news', '/Plone/news/aggregator', '/Plone/events', '/Plone/events/aggregator', '/Plone/Members', '/Plone/test/test-glossary/plone', '/Plone/test']
>>> obj=documents[0].getObject()
>>> [x for x in dir(obj) if x.find('ubject')!=-1]
['Subject', 'Subject__roles__', 'setSubject', 'setSubject__roles__', 'subject']
>>> sub=('abcdef','dhijk','Plone is great')
>>> obj.setSubject(sub)
>>> obj.subject
(u'abcdef', u'dhijk', u'Plone is great')
>>> import transaction
>>> transaction.commit()

that was not a success, in fact Subject is not the 'summary' in the UI, it's the tags so
let's try again

>>> [x for x in dir(obj) if x[0]!='_' and x[-1:]!='_']
['COPY', 'Contributors', 'CreationDate', 'Creator', 'DELETE', 'Date', 'Description', 'EffectiveDate', 'ExpirationDate', 'Format', 'HEAD', 'Identifier', 'LOCK', 'Language', 'MKCOL', 'MOVE', 'ModificationDate', 'OPTIONS', 'PROPFIND', 'PROPPATCH', 'PUT', 'Publisher', 'REQUEST', 'Rights', 'SearchableText', 'Subject', 'TRACE', 'Title', 'Type', 'UID', 'UNLOCK', 'absolute_url', 'absolute_url_path', 'ac_inherited_permissions', 'access_debug_info', 'aclAChecked', 'aclEChecked', 'aclPChecked', 'acquiredRolesAreUsedBy', 'addCreator', 'aliases', 'allow_discussion', 'bobobase_modification_time', 'canSetDefaultPage', 'canSetLayout', 'cb_isCopyable', 'cb_isMoveable', 'cb_userHasCopyOrMovePermission', 'changeOwnership', 'cmf_uid', 'content_type', 'contributors', 'created', 'creation_date', 'creators', 'dav__init', 'dav__simpleifhandler', 'dav__validate', 'defaultView', 'default_view', 'description', 'effective', 'effective_date', 'exclude_from_nav', 'expiration_date', 'expires', 'failIfLocked', 'filtered_manage_options', 'format', 'getActionInfo', 'getAttribute', 'getAttributeNode', 'getAttributes', 'getAvailableLayouts', 'getChildNodes', 'getDefaultLayout', 'getDefaultPage', 'getElementsByTagName', 'getFirstChild', 'getIcon', 'getIconURL', 'getId', 'getLastChild', 'getLayout', 'getNextSibling', 'getNodeName', 'getNodeType', 'getNodeValue', 'getOwner', 'getOwnerDocument', 'getOwnerTuple', 'getParentNode', 'getPhysicalPath', 'getPhysicalRoot', 'getPortalTypeName', 'getPreviousSibling', 'getProperty', 'getPropertyType', 'getTagName', 'getTypeInfo', 'getWrappedOwner', 'get_local_roles', 'get_local_roles_for_userid', 'get_size', 'get_valid_userids', 'hasChildNodes', 'hasProperty', 'has_local_roles', 'http__etag', 'http__parseMatchList', 'http__processMatchHeaders', 'http__refreshEtag', 'icon', 'id', 'indexObject', 'isEffective', 'isPrincipiaFolderish', 'isTopLevelPrincipiaApplicationObject', 'language', 'listContributors', 'listCreators', 'listDAVObjects', 'location_id', 'manage', 'manage_DAVget', 'manage_FTPget', 'manage_FTPlist', 'manage_FTPstat', 'manage_UndoForm', 'manage_access', 'manage_acquiredForm', 'manage_acquiredPermissions', 'manage_addLocalRoles', 'manage_addProperty', 'manage_afterAdd', 'manage_afterClone', 'manage_beforeDelete', 'manage_changeOwnershipType', 'manage_changePermissions', 'manage_changeProperties', 'manage_changePropertyTypes', 'manage_defined_roles', 'manage_delLocalRoles', 'manage_delProperties', 'manage_editLocalRoles', 'manage_editProperties', 'manage_editRoles', 'manage_editedDialog', 'manage_fixupOwnershipAfterAdd', 'manage_getPermissionMapping', 'manage_getUserRolesAndPermissions', 'manage_listLocalRoles', 'manage_options', 'manage_owner', 'manage_permission', 'manage_permissionForm', 'manage_propertiesForm', 'manage_propertyTypeForm', 'manage_reportUserPermissions', 'manage_role', 'manage_roleForm', 'manage_setLocalRoles', 'manage_setPermissionMapping', 'manage_tabs', 'manage_takeOwnership', 'manage_undo_transactions', 'manage_workflowsTab', 'manage_workspace', 'meta_type', 'modification_date', 'modified', 'notifyModified', 'notifyWorkflowCreated', 'objectIds', 'objectItems', 'objectValues', 'opaqueIds', 'opaqueItems', 'opaqueValues', 'owner_info', 'permissionMappingPossibleValues', 'permission_settings', 'permissionsOfRole', 'portal_type', 'possible_permissions', 'propdict', 'propertyDescription', 'propertyIds', 'propertyItems', 'propertyLabel', 'propertyMap', 'propertyValues', 'propertysheets', 'raise_standardErrorMessage', 'reindexObject', 'reindexObjectSecurity', 'relatedItems', 'restrictedTraverse', 'rights', 'rolesOfPermission', 'selectedRoles', 'setContributors', 'setCreators', 'setDefaultPage', 'setDescription', 'setEffectiveDate', 'setExpirationDate', 'setFormat', 'setLanguage', 'setLayout', 'setModificationDate', 'setRights', 'setSubject', 'setTitle', 'smallRolesWidget', 'subject', 'suppl_views', 'table_of_contents', 'tabs_path_default', 'tabs_path_info', 'text', 'this', 'title', 'title_and_id', 'title_or_id', 'tpURL', 'tpValues', 'undoable_transactions', 'unindexObject', 'unrestrictedTraverse', 'userCanTakeOwnership', 'userdefined_roles', 'users_with_local_role', 'validRoles', 'valid_property_id', 'valid_roles', 'validate_roles', 'version_id', 'virtual_url_path', 'wl_clearLocks', 'wl_delLock', 'wl_getLock', 'wl_hasLock', 'wl_isLocked', 'wl_lockItems', 'wl_lockTokens', 'wl_lockValues', 'wl_lockmapping', 'wl_setLock', 'workflow_history']
>>> obj.SearchableText()
'test2 desc 1'

not good

>>> obj.Description()
'desc 1'

yes, that's it

>>> obj.setDescription(u'desc 1\ndesc2\ndesc3')
>>> obj.Description()
'desc 1 desc2 desc3'
>>> obj.setDescription((u'desc 1',u'desc2',u'desc3'))
>>> obj.Description()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/plone-5.1-latest/buildout-cache/eggs/plone.dexterity-2.5.4-py2.7.egg/plone/dexterity/content.py", line 425, in Description
    value = value.replace('\r\n', ' ').replace('\r', ' ').replace('\n', ' ')  # noqa
AttributeError: 'tuple' object has no attribute 'replace'

ouch !

>>> import transaction
>>> transaction.abort()
>>> obj.Description()
'desc 1'
>>> obj.setDescription(u'desc 1\r\ndesc2\r\ndesc3')
>>> obj.Description()
'desc 1 desc2 desc3'
>>> import transaction
>>> transaction.commit()

it seems that Subject should be set with a tuple and the method setSubject, and the summary (Description in the API) using a string with CR/LF
This is looking fine in the UI.
Ah, don't forget to call reindexObject when all is done.

1 Like