Grant permissions to the object created

Hi friends,
I have created a folder called "Documents" in my plone site. I want to grant permissions for that folder programatically .


I am getting the following error

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.autoform.view, line 47, in call
Module plone.autoform.view, line 38, in render
Module Products.Five.browser.pagetemplatefile, line 125, in call
Module Products.Five.browser.pagetemplatefile, line 59, in call
Module zope.pagetemplate.pagetemplate, line 132, in pt_render
Module, line 93, in call
Module, line 163, in render
Module chameleon.zpt.template, line 261, in render
Module chameleon.template, line 191, in render
Module chameleon.template, line 171, in render
Module, line 132, in render
Module, line 1223, in render_master
Module, line 420, in render_content
Module, line 103, in __fill_content_core
Module fincrm.contents.browser.documents, line 20, in docView
Module OFS.ObjectManager, line 784, in getitem
KeyError: 'Documents'

  • Expression: "python:view.docView()"
  • Filename: ... m.contents/src/fincrm/contents/browser/templates/
  • Location: (line 8: col 21)
  • Source:
  • Arguments: repeat: {...} (0)
    template: <ViewPageTemplateFile - at 0x7f1019a987d0>
    views: <ViewMapper - at 0x7f1019561890>
    modules: <instance - at 0x7f10249b7128>
    args: <tuple - at 0x7f102d2b6050>
    here: <ImplicitAcquisitionWrapper documents at 0x7f101bc17d70>
    user: <ImplicitAcquisitionWrapper - at 0x7f101bc178c0>
    nothing: <NoneType - at 0x55713e2a5560>
    container: <ImplicitAcquisitionWrapper documents at 0x7f101bc17d70>
    request: <instance - at 0x7f101c11ba70>
    wrapped_repeat: <SafeMapping - at 0x7f101b30cd08>
    traverse_subpath: <list - at 0x7f10182e53f8>
    default: <object - at 0x7f102d1d5550>
    loop: {...} (0)
    context: <ImplicitAcquisitionWrapper documents at 0x7f101bc17d70>
    view: <SimpleViewClass from /home/ananth/Plone/zinstance/src/fincrm.contents/src/fincrm/contents/browser/templates/ docsview at 0x7f1019a4fc50>
    translate: <function translate at 0x7f10197e06e0>
    root: <ImplicitAcquisitionWrapper Zope at 0x7f101be8d6e0>
    options: {...} (0)
    target_language: <NoneType - at 0x55713e2a5560>

Documents is the ID of the folder? or is it documents?

1 Like



The ID is what you have in URL. (yourwebsite/documents)

yes the documents is the id of the folder created by me

You need to use object id to access it, not the title.
Also see

Btw, plone.api.user.grant_roles takes a user, so you don't need to do str(user).