Removing "layout" property — AttributeError: manage_delProperty
David Siedband <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.user |
|---|---|
| Message-ID | <[email protected]> |
In one of our Plone 4 sites, we’re seeing a strange behavior where on some objects that have a “layout” property set (i.e. view selected) the “display” menu disappears and is not rendered at all.
While we try to figure out why this is happening, I wanted to create a script which would site admins to delete that layout property without exposing them to the ZMI. So, I created a script which looks like this:
= = = = = = = = =
from Products.CMFCore.utils import getToolByName
plone_utils = getToolByName(context, 'plone_utils')
r = context.REQUEST
obj = context.aq_explicit
if obj.hasProperty('layout'):
obj.manage_delProperty('layout')
plone_utils.addPortalMessage(_(u'The layout property has been deleted.'), 'info')
else:
plone_utils.addPortalMessage(_(u'This object has no layout property.'), 'info')
return r.RESPONSE.redirect(obj.absolute_url())
= = = = = = = = =
When I run the script I get the following error about "AttributeError: manage_delProperty"
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 Shared.DC.Scripts.Bindings, line 322, in __call__
Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
Module Products.PythonScripts.PythonScript, line 344, in _exec
Module script, line 10, in resetLayout
- <PythonScript at /portal/resetLayout used for /portal/data/regional-geo-data/invertebrates>
- Line 10
AttributeError: manage_delProperty
When I debug this, it appears that obj is in fact the object I want, as it has the correct ID and passes the check for having the “layout” property in the first place.
Am I using the correct method, manage_delProperty()? Any ideas why this would fail?
thanks,
--
David Siedband
http://zentraal.com
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/