2.3.
The permissions module
Up one level
First, we import the standard useful modules:
from Products.CMFCore.permissions import setDefaultRoles
from Products.Archetypes.atapi import listTypes
from config import PROJECTNAME
In this module, we need to define the "Add" permission for the Instant Message type, and set it to the default roles:
# Add an Instant Message
ADD_CONTENT_PERMISSION = 'InstantMessage: Add InstantMessage'
# Assign default roles
setDefaultRoles(ADD_CONTENT_PERMISSION, ('Owner', 'Manager',))
The reason the variable here is UPPERCASED is that it should be treated like a constant, and this makes them easy to spot.
We recommend using the standard way of naming permissions: '<ProductName>: <Permission>'. This will group the related permissions together within the ZMI (Security tab), and allow the Administrator to recognize which permissions belong to which Product.
Note that, unless you have an advanced case which needs custom security settings, you don't need to define your own permissions for the "edit" and "view" of the content. In this simple case you will just reuse, in the modules where needed, the generic permissions defined in CMFCore.permissions: "View", "Modify portal content"...
Not supposed to do this through the ZMI
This tutorial works directly from your local Filesystem you should create a folder/directory for your product, and then create all the separate files and folders as the start of the tutorial mentions.
When you are done with it, you need to put your new product folder, in your products folder of your instance home
don't know how to do this first part of archetypes.
From Home → Documentation → Manuals → Archetypes Developer Manual → A simple AT Product → The permissions module
It says:
First, we import the standard useful modules:
I went to Add Script Python:
from Products.CMFCore.permissions import setDefaultRoles
and get
Error Type: ImportError
Error Value: import of "setDefaultRoles" from "Products.CMFCore.permissions" is unauthorized. You are not allowed to access 'setDefaultRoles' in this context
What do I do to get this right?
Thanks
Bob