コード例 #1
0
def initialize(context):
    """ Initialize product (standard Zope hook)
    """
    registerPermissions([(ADD_DESIGN_PERMISSION, []),
                         (ADD_CONTENT_PERMISSION, []), (READ_PERMISSION, []),
                         (EDIT_PERMISSION, []), (CREATE_PERMISSION, []),
                         (REMOVE_PERMISSION, []), (DESIGN_PERMISSION, []),
                         (ACL_PERMISSION, [])])
    from .document import PlominoDocument, addPlominoDocument

    all_content_types = (PlominoDocument, )
    all_constructors = (addPlominoDocument, )
    all_ftis = ({
        'meta_type': 'PlominoDocument',
        'allowed_content_types': [],
        'allow_discussion': 0,
        'global_allow': 0,
        'filter_content_types': 1,
    }, )

    cmfutils.ContentInit(
        'CMFPlomino Content',
        content_types=all_content_types,
        permission=ADD_CONTENT_PERMISSION,
        extra_constructors=all_constructors,
        fti=all_ftis,
    ).initialize(context)
コード例 #2
0
def initialize(context):
    """ Initialize product (standard Zope hook)
    """
    registerPermissions([(ADD_DESIGN_PERMISSION, []),
                         (ADD_CONTENT_PERMISSION, []),
                         (READ_PERMISSION, []),
                         (EDIT_PERMISSION, []),
                         (CREATE_PERMISSION, []),
                         (REMOVE_PERMISSION, []),
                         (DESIGN_PERMISSION, []),
                         (ACL_PERMISSION, [])])
    from .document import PlominoDocument, addPlominoDocument

    all_content_types = (PlominoDocument,)
    all_constructors = (addPlominoDocument,)
    all_ftis = ({
        'meta_type': 'PlominoDocument',
        'allowed_content_types': [],
        'allow_discussion': 0,
        'global_allow': 0,
        'filter_content_types': 1,
    }, )

    cmfutils.ContentInit(
        'CMFPlomino Content',
        content_types=all_content_types,
        permission=ADD_CONTENT_PERMISSION,
        extra_constructors=all_constructors,
        fti=all_ftis,
    ).initialize(context)
コード例 #3
0
ファイル: __init__.py プロジェクト: CGTIC/Plone_SP
def initialize(context):
    # Register the helpfile
    if hasattr(context, 'registerHelp'):
        context.registerHelp()
        context.registerHelpTitle('DocFinderTab')

    # Register our permission
    registerPermissions(((ViewDocPermission, (), ViewDocDefaultRoles),))
コード例 #4
0
ファイル: __init__.py プロジェクト: nilbacardit26/plone_prova
def initialize(context):
    # Register the helpfile
    if hasattr(context, 'registerHelp'):
        context.registerHelp()
        context.registerHelpTitle('DocFinderTab')

    # Register our permission
    registerPermissions(((ViewDocPermission, (), ViewDocDefaultRoles), ))
コード例 #5
0
ファイル: __init__.py プロジェクト: devamuttewar/Plomino
def initialize(context):
    """ Initialize product (standard Zope hook)
    """
    ##code-section custom-init-top #fill in your manual code here
    registerPermissions([(ADD_DESIGN_PERMISSION, []),
                         (ADD_CONTENT_PERMISSION, []), (READ_PERMISSION, []),
                         (EDIT_PERMISSION, []), (CREATE_PERMISSION, []),
                         (REMOVE_PERMISSION, []), (DESIGN_PERMISSION, []),
                         (ACL_PERMISSION, [])])
    ##/code-section custom-init-top

    # imports packages and types for registration

    import PlominoDatabase
    import PlominoAction
    import PlominoForm
    import PlominoField
    import PlominoView
    import PlominoColumn
    import PlominoDocument
    import PlominoHidewhen
    import PlominoAgent
    import PlominoCache
    from PlominoDocument import addPlominoDocument

    # Initialize portal content
    all_content_types, all_constructors, all_ftis = process_types(
        listTypes(PROJECTNAME), PROJECTNAME)

    all_content_types += (PlominoDocument.PlominoDocument, )
    all_constructors += (addPlominoDocument, )
    all_ftis += ({
        'meta_type': 'PlominoDocument',
        'allowed_content_types': [],
        'allow_discussion': 0,
        'immediate_view': 'checkBeforeOpenDocument',
        'global_allow': 0,
        'filter_content_types': 1,
    }, )
    #EXAMPLE: {'factory': 'addPlominoAction', 'product': 'CMFPlomino', 'immediate_view': 'base_edit', 'content_icon': 'document_icon.gif', 'global_allow': True, 'filter_content_types': False, 'actions': ({'action': <Products.CMFCore.Expression.Expression object at 0x6bee8c0>, 'title': 'View', 'id': 'view', 'permissions': ('View',)}, {'action': <Products.CMFCore.Expression.Expression object at 0x6bee758>, 'title': 'Edit', 'id': 'edit', 'condition': <Products.CMFCore.Expression.Expression object at 0x6e247d0>, 'permissions': ('Modify portal content',)}, {'action': <Products.CMFCore.Expression.Expression object at 0x6d9dd70>, 'title': 'Properties', 'id': 'metadata', 'permissions': ('Modify portal content',)}), 'fti_meta_type': 'Factory-based Type Information with dynamic views', 'default_view': 'base_view', 'meta_type': 'PlominoAction', 'allow_discussion': False, 'view_methods': ('base_view',), 'aliases': {'sharing': 'folder_localrole_form', 'gethtml': '', '(Default)': '(dynamic view)', 'edit': 'base_edit', 'mkdir': '', 'properties': 'base_metadata', 'view': '(selected layout)'}, 'id': 'PlominoAction', 'description': '\n    '}

    cmfutils.ContentInit(
        PROJECTNAME + ' Content',
        content_types=all_content_types,
        permission=DEFAULT_ADD_CONTENT_PERMISSION,
        extra_constructors=all_constructors,
        fti=all_ftis,
    ).initialize(context)

    # Give it some extra permissions to control them on a per class limit
    for i in range(0, len(all_content_types)):
        klassname = all_content_types[i].__name__
        if not klassname in ADD_CONTENT_PERMISSIONS:
            continue

        context.registerClass(meta_type=all_ftis[i]['meta_type'],
                              constructors=(all_constructors[i], ),
                              permission=ADD_CONTENT_PERMISSIONS[klassname])
コード例 #6
0
ファイル: utils.py プロジェクト: goschtl/zope
 def register_additional_permissions(self, permissions):
     if isinstance(permissions, basestring): # You goofed it!
         raise TypeError, ('Product context permissions should be a '
             'list of permissions not a string', permissions)
     for p in permissions:
         if isinstance(p, tuple):
             p, default= p
             registerPermissions(((p, (), default),))
         else:
             registerPermissions(((p, ()),))
コード例 #7
0
ファイル: utils.py プロジェクト: bendavis78/zope
 def register_additional_permissions(self, permissions):
     if isinstance(permissions, basestring):  # You goofed it!
         raise TypeError, ('Product context permissions should be a '
                           'list of permissions not a string', permissions)
     for p in permissions:
         if isinstance(p, tuple):
             p, default = p
             registerPermissions(((p, (), default), ))
         else:
             registerPermissions(((p, ()), ))
コード例 #8
0
ファイル: utils.py プロジェクト: bendavis78/zope
    def register_constructor_permission(self, permission, meta_type,
                                        instance_class):
        if permission is None:
            permission = "Add %ss" % (meta_type or instance_class.meta_type)

        if isinstance(permission, tuple):
            permission, default = permission
        else:
            default = ('Manager', )

        pr = PermissionRole(permission, default)
        registerPermissions(((permission, (), default), ))
        return pr, permission
コード例 #9
0
ファイル: utils.py プロジェクト: goschtl/zope
    def register_constructor_permission(self, permission, meta_type,
                                        instance_class):
        if permission is None:
            permission = "Add %ss" % (meta_type or instance_class.meta_type)

        if isinstance(permission, tuple):
            permission, default = permission
        else:
            default = ('Manager',)

        pr = PermissionRole(permission,default)
        registerPermissions(((permission, (), default),))
        return pr, permission
コード例 #10
0
ファイル: setuphandlers.py プロジェクト: EU-OSHA/osha.policy
def configurePortal(portal):
    """ make some changes to the portal config """
    site_properties = getToolByName(
        portal, 'portal_properties').site_properties
    default_page = site_properties.getProperty('default_page')
    default_page += ('index.php', 'index.stm', 'index.stml')
    site_properties._updateProperty('default_page', default_page)

    portal._addRole('Checker')
    registerPermissions([('Crosscheck portal content', None)])
    portal.manage_permission(
        'Crosscheck portal content', roles=['Manager', 'Checker'], acquire=0)

    # remove LinguaLink from portal workflow chain
    portal_workflow = getToolByName(portal, 'portal_workflow')
    portal_workflow.setChainForPortalTypes(['LinguaLink'], None)
コード例 #11
0
def initialize(context):
    """initialize product (called by zope)"""
    ##code-section custom-init-top #fill in your manual code here
    registerPermissions([(ADD_DESIGN_PERMISSION, []),
                         (ADD_CONTENT_PERMISSION, []), (READ_PERMISSION, []),
                         (EDIT_PERMISSION, []), (CREATE_PERMISSION, []),
                         (REMOVE_PERMISSION, []), (DESIGN_PERMISSION, []),
                         (ACL_PERMISSION, [])])
    ##/code-section custom-init-top

    # imports packages and types for registration

    import PlominoDatabase
    import PlominoAction
    import PlominoForm
    import PlominoField
    import PlominoView
    import PlominoColumn
    import PlominoDocument
    import PlominoHidewhen
    import PlominoAgent

    # Initialize portal content
    all_content_types, all_constructors, all_ftis = process_types(
        listTypes(PROJECTNAME), PROJECTNAME)

    cmfutils.ContentInit(
        PROJECTNAME + ' Content',
        content_types=all_content_types,
        permission=DEFAULT_ADD_CONTENT_PERMISSION,
        extra_constructors=all_constructors,
        fti=all_ftis,
    ).initialize(context)

    # Give it some extra permissions to control them on a per class limit
    for i in range(0, len(all_content_types)):
        klassname = all_content_types[i].__name__
        if not klassname in ADD_CONTENT_PERMISSIONS:
            continue

        context.registerClass(meta_type=all_ftis[i]['meta_type'],
                              constructors=(all_constructors[i], ),
                              permission=ADD_CONTENT_PERMISSIONS[klassname])
コード例 #12
0
    def registerClass(self,
                      instance_class=None,
                      meta_type='',
                      permission=None,
                      constructors=(),
                      icon=None,
                      permissions=None,
                      legacy=(),
                      visibility="Global",
                      interfaces=_marker,
                      container_filter=None):
        """Register a constructor

        Keyword arguments are used to provide meta data:

        instance_class -- The class of the object that will be created.

          This is not currently used, but may be used in the future to
          increase object mobility.

        meta_type -- The kind of object being created
           This appears in add lists.  If not specified, then the class
           meta_type will be used.

        permission -- The permission name for the constructors.
           If not specified, then a permission name based on the
           meta type will be used.

        constructors -- A list of constructor methods
          A method can be a callable object with a __name__
          attribute giving the name the method should have in the
          product, or the method may be a tuple consisting of a
          name and a callable object.  The method must be picklable.

          The first method will be used as the initial method called
          when creating an object.

        icon -- No longer used.

        permissions -- Additional permissions to be registered
           If not provided, then permissions defined in the
           class will be registered.

        legacy -- A list of legacy methods to be added to ObjectManager
                  for backward compatibility

        visibility -- "Global" if the object is globally visible, None else

        interfaces -- a list of the interfaces the object supports

        container_filter -- function that is called with an ObjectManager
           object as the only parameter, which should return a true object
           if the object is happy to be created in that container. The
           filter is called before showing ObjectManager's Add list,
           and before pasting (after object copy or cut), but not
           before calling an object's constructor.

        """
        pack = self.__pack
        initial = constructors[0]
        productObject = self.__prod
        pid = productObject.id

        if permissions:
            if isinstance(permissions, str):  # You goofed it!
                raise TypeError(
                    'Product context permissions should be a '
                    'list of permissions not a string', permissions)
            for p in permissions:
                if isinstance(p, tuple):
                    p, default = p
                    registerPermissions(((p, (), default), ))
                else:
                    registerPermissions(((p, ()), ))

        ############################################################
        # Constructor permission setup
        if permission is None:
            permission = "Add %ss" % (meta_type or instance_class.meta_type)

        if isinstance(permission, tuple):
            permission, default = permission
        else:
            default = ('Manager', )

        pr = PermissionRole(permission, default)
        registerPermissions(((permission, (), default), ))
        ############################################################

        OM = ObjectManager

        for method in legacy:
            if isinstance(method, tuple):
                name, method = method
                aliased = 1
            else:
                name = method.__name__
                aliased = 0
            if name not in OM.__dict__:
                setattr(OM, name, method)
                setattr(OM, name + '__roles__', pr)
                if aliased:
                    # Set the unaliased method name and its roles
                    # to avoid security holes.  XXX: All "legacy"
                    # methods need to be eliminated.
                    setattr(OM, method.__name__, method)
                    setattr(OM, method.__name__ + '__roles__', pr)

        if isinstance(initial, tuple):
            name, initial = initial
        else:
            name = initial.__name__

        fd = getattr(pack, '__FactoryDispatcher__', None)
        if fd is None:

            class __FactoryDispatcher__(FactoryDispatcher):
                "Factory Dispatcher for a Specific Product"

            fd = pack.__FactoryDispatcher__ = __FactoryDispatcher__

        if not hasattr(pack, '_m'):
            pack._m = AttrDict(fd)

        m = pack._m

        if interfaces is _marker:
            if instance_class is None:
                interfaces = ()
            else:
                interfaces = tuple(implementedBy(instance_class))

        Products.meta_types = Products.meta_types + (
            {
                'name': meta_type or instance_class.meta_type,
                # 'action': The action in the add drop down in the ZMI. This is
                #           currently also required by the _verifyObjectPaste
                #           method of CopyContainers like Folders.
                'action': ('manage_addProduct/%s/%s' % (pid, name)),
                # 'product': product id
                'product': pid,
                # 'permission': Guards the add action.
                'permission': permission,
                # 'visibility': A silly name. Doesn't have much to do with
                #               visibility. Allowed values: 'Global', None
                'visibility': visibility,
                # 'interfaces': A tuple of oldstyle and/or newstyle interfaces.
                'interfaces': interfaces,
                'instance': instance_class,
                'container_filter': container_filter
            }, )

        m[name] = initial
        m[name + '__roles__'] = pr

        for method in constructors[1:]:
            if isinstance(method, tuple):
                name, method = method
            else:
                name = os.path.split(method.__name__)[-1]
            if name not in productObject.__dict__:
                m[name] = method
                m[name + '__roles__'] = pr
コード例 #13
0
from Products.PloneKeywordManager import tool

global cmf_keyword_manager_globals

import pkg_resources

try:
    pkg_resources.get_distribution('plone.dexterity')
except pkg_resources.DistributionNotFound:
    HAS_DEXTERITY = False
else:
    HAS_DEXTERITY = True

cmf_keyword_manager_globals = globals()

from zope.i18nmessageid import MessageFactory
keywordmanagerMessageFactory = MessageFactory('Products.PloneKeywordManager')
import logging
logger = logging.getLogger("Products.PloneKeywordManager")

registerPermissions([(config.MANAGE_KEYWORDS_PERMISSION, [])],
                    ('Manager', 'Site Administrator'))


def initialize(context):

    new_tool = ToolInit(config.TOOL_NAME,
                        tools=(tool.PloneKeywordManager, ),
                        icon='tool.gif')
    new_tool.initialize(context)
コード例 #14
0
ファイル: ProductContext.py プロジェクト: dhavlik/Zope
    def registerClass(self, instance_class=None, meta_type='',
                      permission=None, constructors=(),
                      icon=None, permissions=None, legacy=(),
                      visibility="Global", interfaces=_marker,
                      container_filter=None):
        """Register a constructor

        Keyword arguments are used to provide meta data:

        instance_class -- The class of the object that will be created.

          This is not currently used, but may be used in the future to
          increase object mobility.

        meta_type -- The kind of object being created
           This appears in add lists.  If not specified, then the class
           meta_type will be used.

        permission -- The permission name for the constructors.
           If not specified, then a permission name based on the
           meta type will be used.

        constructors -- A list of constructor methods
          A method can me a callable object with a __name__
          attribute giving the name the method should have in the
          product, or the method may be a tuple consisting of a
          name and a callable object.  The method must be picklable.

          The first method will be used as the initial method called
          when creating an object.

        icon -- No longer used.

        permissions -- Additional permissions to be registered
           If not provided, then permissions defined in the
           class will be registered.

        legacy -- A list of legacy methods to be added to ObjectManager
                  for backward compatibility

        visibility -- "Global" if the object is globally visible, None else

        interfaces -- a list of the interfaces the object supports

        container_filter -- function that is called with an ObjectManager
           object as the only parameter, which should return a true object
           if the object is happy to be created in that container. The
           filter is called before showing ObjectManager's Add list,
           and before pasting (after object copy or cut), but not
           before calling an object's constructor.

        """
        pack = self.__pack
        initial = constructors[0]
        productObject = self.__prod
        pid = productObject.id

        if permissions:
            if isinstance(permissions, basestring):  # You goofed it!
                raise TypeError(
                    'Product context permissions should be a '
                    'list of permissions not a string', permissions)
            for p in permissions:
                if isinstance(p, tuple):
                    p, default = p
                    registerPermissions(((p, (), default),))
                else:
                    registerPermissions(((p, ()),))

        ############################################################
        # Constructor permission setup
        if permission is None:
            permission = "Add %ss" % (meta_type or instance_class.meta_type)

        if isinstance(permission, tuple):
            permission, default = permission
        else:
            default = ('Manager',)

        pr = PermissionRole(permission, default)
        registerPermissions(((permission, (), default),))
        ############################################################

        OM = ObjectManager

        for method in legacy:
            if isinstance(method, tuple):
                name, method = method
                aliased = 1
            else:
                name = method.__name__
                aliased = 0
            if name not in OM.__dict__:
                setattr(OM, name, method)
                setattr(OM, name + '__roles__', pr)
                if aliased:
                    # Set the unaliased method name and its roles
                    # to avoid security holes.  XXX: All "legacy"
                    # methods need to be eliminated.
                    setattr(OM, method.__name__, method)
                    setattr(OM, method.__name__ + '__roles__', pr)

        if isinstance(initial, tuple):
            name, initial = initial
        else:
            name = initial.__name__

        fd = getattr(pack, '__FactoryDispatcher__', None)
        if fd is None:
            class __FactoryDispatcher__(FactoryDispatcher):
                "Factory Dispatcher for a Specific Product"

            fd = pack.__FactoryDispatcher__ = __FactoryDispatcher__

        if not hasattr(pack, '_m'):
            pack._m = AttrDict(fd)

        m = pack._m

        if interfaces is _marker:
            if instance_class is None:
                interfaces = ()
            else:
                interfaces = tuple(implementedBy(instance_class))

        Products.meta_types = Products.meta_types + ({
            'name': meta_type or instance_class.meta_type,
            # 'action': The action in the add drop down in the ZMI. This is
            #           currently also required by the _verifyObjectPaste
            #           method of CopyContainers like Folders.
            'action': ('manage_addProduct/%s/%s' % (pid, name)),
            # 'product': product id
            'product': pid,
            # 'permission': Guards the add action.
            'permission': permission,
            # 'visibility': A silly name. Doesn't have much to do with
            #               visibility. Allowed values: 'Global', None
            'visibility': visibility,
            # 'interfaces': A tuple of oldstyle and/or newstyle interfaces.
            'interfaces': interfaces,
            'instance': instance_class,
            'container_filter': container_filter
        },)

        m[name] = initial
        m[name + '__roles__'] = pr

        for method in constructors[1:]:
            if isinstance(method, tuple):
                name, method = method
            else:
                name = os.path.split(method.__name__)[-1]
            if name not in productObject.__dict__:
                m[name] = method
                m[name + '__roles__'] = pr
コード例 #15
0
ファイル: __init__.py プロジェクト: gocept/Products.Formulon
def initialize(context):
    try:
        context.registerClass(
            ErrorTranslator.ErrorTranslator,
            constructors=(ErrorTranslator.createErrorTranslator, ),
            icon='www/TranslationRegistry.gif')
        context.registerClass(
            ErrorTranslator.ErrorTranslationRule,
            constructors=(ErrorTranslator.manage_addErrorTranslationRule,
                          ErrorTranslator.createErrorTranslationRule),
            icon='www/translationrule.gif',
            container_filter=ErrorTranslatorFilter)
        context.registerClass(ErrorTranslator.ErrorTranslationRuleGroup,
                              constructors=(ErrorTranslator.manage_addETRG,
                                            ErrorTranslator.createETRG),
                              icon='www/TranslationRegistry.gif',
                              container_filter=ErrorTranslatorFilter)

        context.registerClass(HTMLForm.HTMLForm,
                              constructors=(HTMLForm.manage_addHTMLFormForm,
                                            HTMLForm.manage_addHTMLForm),
                              icon='www/HTMLForm.png')

        context.registerClass(
            HTMLButton.HTMLButton,
            constructors=(HTMLButton.manage_addHTMLButtonForm,
                          HTMLButton.manage_addHTMLButton),
            icon='www/HTMLButton.png',
            container_filter=HTMLFormFilter)

        context.registerClass(HTMLLabel.HTMLLabel,
                              constructors=(HTMLLabel.manage_addHTMLLabelForm,
                                            HTMLLabel.manage_addHTMLLabel),
                              icon='www/HTMLLabel.png',
                              container_filter=HTMLFormFilter)

        context.registerClass(
            HTMLTextfield.HTMLTextfield,
            constructors=(HTMLTextfield.manage_addHTMLTextfieldForm,
                          HTMLTextfield.manage_addHTMLTextfield),
            icon='www/HTMLTextfield.png',
            container_filter=HTMLFormFilter)

        context.registerClass(
            HTMLTextarea.HTMLTextarea,
            constructors=(HTMLTextarea.manage_addHTMLTextareaForm,
                          HTMLTextarea.manage_addHTMLTextarea),
            icon='www/HTMLTextarea.png',
            container_filter=HTMLFormFilter)

        context.registerClass(HTMLMenu.HTMLMenu,
                              constructors=(HTMLMenu.manage_addHTMLMenuForm,
                                            HTMLMenu.manage_addHTMLMenu),
                              icon='www/HTMLMenu.png',
                              container_filter=HTMLFormFilter)

        context.registerClass(
            HTMLDisplay.HTMLDisplay,
            constructors=(HTMLDisplay.manage_addHTMLDisplayForm,
                          HTMLDisplay.manage_addHTMLDisplay),
            icon='www/HTMLDisplay.png',
            container_filter=HTMLFormFilter)

        context.registerClass(HTMLFileupload.HTMLFileupload,
                              constructors=(
                                  HTMLFileupload.manage_addHTMLFileuploadForm,
                                  HTMLFileupload.manage_addHTMLFileupload,
                              ),
                              icon='www/HTMLFileupload.png',
                              container_filter=HTMLFormFilter)

        # Register help documents
        context.registerHelp()

        # Register permissions
        registerPermissions([(permissions.READFIELD, ()),
                             (permissions.WRITEFIELD, ())])

    except:
        import sys, traceback, string
        type, val, tb = sys.exc_info()
        sys.stderr.write(string.join(traceback.format_exception(type, val, \
                                 tb), ''))
        del type, val, tb
コード例 #16
0
ファイル: class_init.py プロジェクト: bendavis78/zope
def InitializeClass(self):
    from AccessControl.Permission import registerPermissions
    from AccessControl.PermissionRole import PermissionRole
    dict=self.__dict__
    have=dict.has_key
    ft=type(InitializeClass)
    dict_items=dict.items()

    for name, v in dict_items:
        if getattr(v, '_need__name__', 0):
            d = v.__dict__
            oldname = d.get('__name__', '')
            if d.get('_implicit__name__', 0):
                # Already supplied a name.
                if name != oldname:
                    # Tried to implicitly assign a different name!
                    try: classname = '%s.%s' % (
                        self.__module__, self.__name__)
                    except AttributeError: classname = `self`
                    logging.getLogger("Init").warning(
                        'Ambiguous name for method of %s: %r != %r',
                        classname, d['__name__'], name)
            else:
                # Supply a name implicitly so that the method can
                # find the security assertions on its container.
                v._implicit__name__ = 1
                v.__name__ = name
            if name=='manage' or name[:7]=='manage_':
                name=name+'__roles__'
                if not have(name):
                    setattr(self, name, ('Manager',))
        elif name=='manage' or name[:7]=='manage_' and type(v) is ft:
            name=name+'__roles__'
            if not have(name):
                setattr(self, name, ('Manager',))
                
    # Look for a SecurityInfo object on the class. If found, call its
    # apply() method to generate __ac_permissions__ for the class. We
    # delete the SecurityInfo from the class dict after it has been
    # applied out of paranoia.
    for key, value in dict_items:
        if hasattr(value, '__security_info__'):
            security_info=value
            security_info.apply(self)
            delattr(self, key)
            break

    if self.__dict__.has_key('__ac_permissions__'):
        registerPermissions(self.__ac_permissions__)
        for acp in self.__ac_permissions__:
            pname, mnames = acp[:2]
            if len(acp) > 2:
                roles = acp[2]
                pr = PermissionRole(pname, roles)
            else:
                pr = PermissionRole(pname)
            for mname in mnames:
                setattr(self, mname+'__roles__', pr)
                if (mname and mname not in ('context', 'request') and
                    not hasattr(self, mname)):
                    # don't complain about context or request, as they are
                    # frequently not available as class attributes
                    logging.getLogger("Init").warning(
                        "Class %s.%s has a security declaration for "
                        "nonexistent method %r", self.__module__,
                        self.__name__, mname)
コード例 #17
0
ファイル: __init__.py プロジェクト: peterbe/zope_products
def initialize(context):
        
    registerPermissions(((ViewCTPermission, (), ViewCTDefaultRoles),))
コード例 #18
0
global cmf_keyword_manager_globals

import pkg_resources

try:
    pkg_resources.get_distribution('plone.dexterity')
except pkg_resources.DistributionNotFound:
    HAS_DEXTERITY = False
else:
    HAS_DEXTERITY = True


cmf_keyword_manager_globals = globals()

from zope.i18nmessageid import MessageFactory
keywordmanagerMessageFactory = MessageFactory('Products.PloneKeywordManager')
import logging
logger = logging.getLogger("Products.PloneKeywordManager")


registerPermissions(
    [(config.MANAGE_KEYWORDS_PERMISSION, [])],
    ('Manager', 'Site Administrator'))


def initialize(context):

    new_tool = ToolInit(
        config.TOOL_NAME, tools=(tool.PloneKeywordManager, ), icon='tool.gif')
    new_tool.initialize(context)
コード例 #19
0
ファイル: __init__.py プロジェクト: Vinsurya/Plone
def initialize(context):
    """ Initialize product (standard Zope hook)
    """
    ##code-section custom-init-top #fill in your manual code here
    registerPermissions([(ADD_DESIGN_PERMISSION, []),
                         (ADD_CONTENT_PERMISSION, []),
                         (READ_PERMISSION, []),
                         (EDIT_PERMISSION, []),
                         (CREATE_PERMISSION, []),
                         (REMOVE_PERMISSION, []),
                         (DESIGN_PERMISSION, []),
                         (ACL_PERMISSION, [])])
    ##/code-section custom-init-top

    # imports packages and types for registration

    import PlominoDatabase
    import PlominoAction
    import PlominoForm
    import PlominoField
    import PlominoView
    import PlominoColumn
    import PlominoDocument
    import PlominoHidewhen
    import PlominoAgent
    import PlominoCache
    from PlominoDocument import addPlominoDocument

    # Initialize portal content
    all_content_types, all_constructors, all_ftis = process_types(
        listTypes(PROJECTNAME),
        PROJECTNAME)

    all_content_types += (PlominoDocument.PlominoDocument,)
    all_constructors += (addPlominoDocument,)
    all_ftis += ({
                'meta_type': 'PlominoDocument',
                'allowed_content_types': [],
                'allow_discussion': 0,
                'immediate_view': 'checkBeforeOpenDocument',
                'global_allow': 0,
                'filter_content_types': 1,
                },)
#EXAMPLE: {'factory': 'addPlominoAction', 'product': 'CMFPlomino', 'immediate_view': 'base_edit', 'content_icon': 'document_icon.gif', 'global_allow': True, 'filter_content_types': False, 'actions': ({'action': <Products.CMFCore.Expression.Expression object at 0x6bee8c0>, 'title': 'View', 'id': 'view', 'permissions': ('View',)}, {'action': <Products.CMFCore.Expression.Expression object at 0x6bee758>, 'title': 'Edit', 'id': 'edit', 'condition': <Products.CMFCore.Expression.Expression object at 0x6e247d0>, 'permissions': ('Modify portal content',)}, {'action': <Products.CMFCore.Expression.Expression object at 0x6d9dd70>, 'title': 'Properties', 'id': 'metadata', 'permissions': ('Modify portal content',)}), 'fti_meta_type': 'Factory-based Type Information with dynamic views', 'default_view': 'base_view', 'meta_type': 'PlominoAction', 'allow_discussion': False, 'view_methods': ('base_view',), 'aliases': {'sharing': 'folder_localrole_form', 'gethtml': '', '(Default)': '(dynamic view)', 'edit': 'base_edit', 'mkdir': '', 'properties': 'base_metadata', 'view': '(selected layout)'}, 'id': 'PlominoAction', 'description': '\n    '}

    cmfutils.ContentInit(
        PROJECTNAME + ' Content',
        content_types=all_content_types,
        permission=DEFAULT_ADD_CONTENT_PERMISSION,
        extra_constructors=all_constructors,
        fti=all_ftis,
        ).initialize(context)

    # Give it some extra permissions to control them on a per class limit
    for i in range(0, len(all_content_types)):
        klassname = all_content_types[i].__name__
        if not klassname in ADD_CONTENT_PERMISSIONS:
            continue

        context.registerClass(
                meta_type=all_ftis[i]['meta_type'],
                constructors=(all_constructors[i],),
                permission=ADD_CONTENT_PERMISSIONS[klassname]
                )
コード例 #20
0
ファイル: __init__.py プロジェクト: gocept/gocept.alphaflow
def registerPermission(permission, default_roles):
    registerPermissions([(permission, [])], default_roles)
コード例 #21
0
#
# More info about Levenshtein on:
# http://trific.ath.cx/resources/python/levenshtein/
##
###
from AccessControl.Permission import registerPermissions
from Products.CMFCore.utils import ToolInit
from Products.PloneKeywordManager import config
from Products.PloneKeywordManager import tool
from zope.i18nmessageid import MessageFactory

import logging

global cmf_keyword_manager_globals

cmf_keyword_manager_globals = globals()

keywordmanagerMessageFactory = MessageFactory("Products.PloneKeywordManager")
logger = logging.getLogger("Products.PloneKeywordManager")

registerPermissions([(config.MANAGE_KEYWORDS_PERMISSION, [])],
                    ("Manager", "Site Administrator"))


def initialize(context):

    new_tool = ToolInit(config.TOOL_NAME,
                        tools=(tool.PloneKeywordManager, ),
                        icon="tool.gif")
    new_tool.initialize(context)