Re: Removing "layout" property — AttributeError: manage_delProperty
Johannes Raggam <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.user |
|---|---|
| Message-ID | <[email protected]> |
Did you find out, why the "Display" menu disappears? If not, maybe you find some answer in plone.app.contentmenu.menu module's DisplaySubMenuItem. There's a "disabled" method. I overwrote it once to be displayed also in folder_contents views like so: https://github.com/collective/collective.folderishtraverse/blob/master/collective/folderishtraverse/contentmenu.py#L25 Best, Johannes On Fri, 2014-08-22 at 04:19 -0300, David Siedband wrote: > Hi Dieter, > > On Aug 22, 2014, at 3:24 AM, dieter <[email protected]> wrote: > > > David Siedband <[email protected]> writes: > >> ... > >> 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 > > > > "OFS.PropertyManager.PropertyManager" has the method > > "manage_delProperties" (but no "manage_delProperty"). > > > That did it, thanks. I had stumbled upon this thread which erroneously mentions a “manage_delProperty” method > http://copilotco.com/mail-archives/plone-users.2005/msg00287.html > > It took me a moment to figure out that this method expects a list. For anyone referring to this thread, the syntax that worked for me was: > obj.manage_delProperties(('layout',)) > > Also, in my example code I had neglected to import the PloneMessageFactory, so I also had to add the following at the top of my script > from Products.CMFPlone import PloneMessageFactory as _ > > -- > David Siedband > http://zentraal.com > > > ------------------------------------------------------------------------------ > Slashdot TV. > Video for Nerds. Stuff that matters. > http://tv.slashdot.org/ > _______________________________________________ > Plone-Users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/plone-users -- programmatic web development di(fh) johannes raggam / thet python plone zope development plone framework team member mail: office-//[email protected] web: http://programmatic.pro http://bluedynamics.com ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ _______________________________________________ Plone-Users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/plone-users
signature.asc
(application/pgp-signature, 181 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEABECAAYFAlP2/CUACgkQW4mNMQxDgAdhfACgsL14+5NW68ZKuoT5bvKwoMV0 nPAAnjnxl5eIoeMOjVY7uwsCNiZP1uMv =nFNB -----END PGP SIGNATURE-----