You are here: Home / Documentation / How To's / How to fix mysterious Unauthorized errors when trying to add a content item (e.g. News Item)

How to fix mysterious Unauthorized errors when trying to add a content item (e.g. News Item)

by nguyen — published Oct 05, 2010 02:31 PM, last modified Aug 16, 2016 10:50 AM
even though you are logged in with Manager role (in Plone site or in Zope) you still cannot add a News Item and you get an unauthorized error

First thing to do is go into the ZMI error_log and comment out the Unauthorized exception, save, then reproduce the problem.  When you refresh the error_log you will see the new Unauthorized error.

In our particular case, the first error looked like this:

Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFPlone.FactoryTool, line 377, in __call__
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFFormController.FSControllerPageTemplate, line 90, in __call__
  Module Products.CMFFormController.BaseControllerPageTemplate, line 31, in _call
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 216, in _exec
  Module Products.CacheSetup.patch_cmf, line 51, in FSPT_pt_render
  Module Products.Gloworm, line 28, in pt_render
  Module zope.pagetemplate.pagetemplate, line 117, in pt_render
   - Warning: Macro expansion failed
   - Warning: exceptions.KeyError: 'macro'
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 534, in do_optTag_tal
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal
  Module Products.PageTemplates.Expressions, line 221, in evaluateStructure
  Module zope.tales.tales, line 696, in evaluate
   - URL: file:/opt/Plone-3.2.3/buildout-cache/eggs/Plone-3.2.3-py2.4.egg/Products/CMFPlone/skins/plone_templates/main_template.pt
   - Line 78, Column 8
   - Expression: <StringExpr u'plone.portaltop'>
   - Names:
      {'container': <PloneSite at /sites1/gradstudies>,
       'context': <ATNewsItem at /sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.9231378231 used for /sites1/gradstudies>,
       'default': <object object at 0x2ac213be4200>,
       'here': <ATNewsItem at /sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.9231378231 used for /sites1/gradstudies>,
       'loop': {},
       'nothing': None,
       'options': {'args': (),
                   'state': <Products.CMFFormController.ControllerState.ControllerState object at 0x2aaaaeae1ad0>},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x2aaaaeaf01b8>,
       'request': <HTTPRequest, URL=http://plone3.webcluster.uwosh.edu:8082/sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.9231378231/atct_edit>,
       'root': <Application at >,
       'template': <FSControllerPageTemplate at /sites1/gradstudies/atct_edit used for /sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.9231378231>,
       'traverse_subpath': [],
       'user': <PropertiedUser 'kimadmin'>}
  Module Products.Five.browser.providerexpression, line 37, in __call__
  Module plone.app.viewletmanager.manager, line 154, in render
  Module plone.app.viewletmanager.manager, line 83, in render
  Module five.customerize.zpt, line 138, in render
  Module Products.PageTemplates.ZopePageTemplate, line 330, in _exec
  Module Products.PageTemplates.ZopePageTemplate, line 427, in pt_render
  Module Products.Gloworm, line 28, in pt_render
  Module zope.pagetemplate.pagetemplate, line 117, in pt_render
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 623, in do_insertText_tal
  Module Products.PageTemplates.Expressions, line 228, in evaluateText
  Module zope.tales.tales, line 696, in evaluate
   - URL: /sites1/gradstudies/portal_factory/Document/document.2010-10-05.8474261792/zope.interface.interface-uwosh.themebase.banner
   - Line 8, Column 4
   - Expression: <PythonExpr here.organization_type>
   - Names:
      {'container': <UnauthorizedBinding: container>,
       'context': <ATNewsItem at /sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.9231378231>,
       'default': <object object at 0x2ac213be4200>,
       'here': <UnauthorizedBinding: context>,
       'loop': {},
       'nothing': None,
       'options': {'args': ()},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x2aaaada14d88>,
       'request': <HTTPRequest, URL=http://plone3.webcluster.uwosh.edu:8082/sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.9231378231/atct_edit>,
       'root': <Application at >,
       'template': <TTWViewTemplate at /sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.9231378231/zope.interface.interface-uwosh.themebase.banner>,
       'user': <PropertiedUser 'kimadmin'>,
       'view': <five.customerize.zpt.TTWViewlet object at 0x2aaaaeb5f7d0>}
  Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__
   - __traceback_info__: here.organization_type
  Module PythonExpr, line 1, in <expression>
Unauthorized: You are not allowed to access 'organization_type' in this context

These customized viewlets sometimes give us grief.  In the past, Python methods defined in the browser view class suddenly were inaccessible once you customized the viewlet.

In this case, you can see that the customized viewlet is uwosh.themebase.banner so we go into ZMI portal_view_customizations and find that viewlet.  Click the Ownership tab.  Click the Take Ownership button.  Try to add a News Item again.

In our case, we then got the following error:

Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFPlone.FactoryTool, line 377, in __call__
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFFormController.FSControllerPageTemplate, line 90, in __call__
  Module Products.CMFFormController.BaseControllerPageTemplate, line 31, in _call
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 216, in _exec
  Module Products.CacheSetup.patch_cmf, line 51, in FSPT_pt_render
  Module Products.Gloworm, line 28, in pt_render
  Module zope.pagetemplate.pagetemplate, line 117, in pt_render
   - Warning: Macro expansion failed
   - Warning: exceptions.KeyError: 'macro'
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 534, in do_optTag_tal
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal
  Module Products.PageTemplates.Expressions, line 221, in evaluateStructure
  Module zope.tales.tales, line 696, in evaluate
   - URL: file:/opt/Plone-3.2.3/buildout-cache/eggs/Plone-3.2.3-py2.4.egg/Products/CMFPlone/skins/plone_templates/main_template.pt
   - Line 78, Column 8
   - Expression: <StringExpr u'plone.portaltop'>
   - Names:
      {'container': <PloneSite at /sites1/gradstudies>,
       'context': <ATNewsItem at /sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.3198086780 used for /sites1/gradstudies>,
       'default': <object object at 0x2ac213be4200>,
       'here': <ATNewsItem at /sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.3198086780 used for /sites1/gradstudies>,
       'loop': {},
       'nothing': None,
       'options': {'args': (),
                   'state': <Products.CMFFormController.ControllerState.ControllerState object at 0x2aaaaedffcd0>},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x2aaaaee36950>,
       'request': <HTTPRequest, URL=http://plone3.webcluster.uwosh.edu:8082/sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.3198086780/atct_edit>,
       'root': <Application at >,
       'template': <FSControllerPageTemplate at /sites1/gradstudies/atct_edit used for /sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.3198086780>,
       'traverse_subpath': [],
       'user': <PropertiedUser 'kimadmin'>}
  Module Products.Five.browser.providerexpression, line 37, in __call__
  Module plone.app.viewletmanager.manager, line 154, in render
  Module plone.app.viewletmanager.manager, line 83, in render
  Module five.customerize.zpt, line 138, in render
  Module Products.PageTemplates.ZopePageTemplate, line 330, in _exec
  Module Products.PageTemplates.ZopePageTemplate, line 427, in pt_render
  Module Products.Gloworm, line 28, in pt_render
  Module zope.pagetemplate.pagetemplate, line 117, in pt_render
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 586, in do_setLocal_tal
  Module zope.tales.tales, line 696, in evaluate
   - URL: /sites1/gradstudies/zope.interface.interface-uwosh.themecollege.sitetitle
   - Line 1, Column 0
   - Expression: <PathExpr standard:u'context/@@plone_context_state/canonical_object_url'>
   - Names:
      {'container': <UnauthorizedBinding: container>,
       'context': <ATNewsItem at /sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.3198086780>,
       'default': <object object at 0x2ac213be4200>,
       'here': <UnauthorizedBinding: context>,
       'loop': {},
       'nothing': None,
       'options': {'args': ()},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x2aaaaee49248>,
       'request': <HTTPRequest, URL=http://plone3.webcluster.uwosh.edu:8082/sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.3198086780/atct_edit>,
       'root': <Application at >,
       'template': <TTWViewTemplate at /sites1/gradstudies/portal_factory/News Item/news_item.2010-10-05.3198086780/zope.interface.interface-uwosh.themecollege.sitetitle>,
       'user': <PropertiedUser 'kimadmin'>,
       'view': <five.customerize.zpt.TTWViewlet object at 0x2aaaaee48a90>}
  Module zope.tales.expressions, line 217, in __call__
  Module Products.PageTemplates.Expressions, line 153, in _eval
  Module zope.tales.expressions, line 124, in _eval
  Module Products.PageTemplates.Expressions, line 80, in boboAwareZopeTraverse
  Module OFS.Traversable, line 301, in restrictedTraverse
  Module OFS.Traversable, line 195, in unrestrictedTraverse
   - __traceback_info__: ([], '@@plone_context_state')
Unauthorized: You are not allowed to access '@@plone_context_state' in this context

This time, the customized viewlet to find is uwosh.themecollege.sitetitle so we find it in the ZMI portal_view_customizations, click the Ownership tab, click the Take Ownership button.  Trying again to add a News Item, this time we succeed.

In our case the original owner of both items is someone who no longer works here but his LDAP email account still exists.  It hasn't been locked.  We don't know why changing ownership fixed the problem.

 

Navigation