Exemplo n.º 1
0
class ISecurityPolicyDirective(Interface):
    """Defines the security policy that will be used for Zope."""

    component = GlobalObject(
        title=_u("Component"),
        description=_u("Pointer to the object that will handle the security."),
        required=True)
Exemplo n.º 2
0
class IModule(Interface):
    """Group security declarations about a module"""

    module = GlobalObject(
        title=_u("Module"),
        description=_u("Pointer to the module object."),
        required=True)
Exemplo n.º 3
0
    def test_system_user(self):
        from zope.security.management import system_user
        from zope.security._compat import TEXT
        from zope.security._compat import _u

        self.assertEqual(system_user.id, _u("zope.security.management.system_user"))

        self.assertEqual(system_user.title, _u("System"))

        for name in "id", "title", "description":
            self.assertTrue(isinstance(getattr(system_user, name), TEXT))
Exemplo n.º 4
0
    def test_system_user(self):
        from zope.security.management import system_user
        from zope.security._compat import TEXT
        from zope.security._compat import _u
        self.assertEqual(system_user.id,
                         _u('zope.security.management.system_user'))

        self.assertEqual(system_user.title, _u('System'))

        for name in 'id', 'title', 'description':
            self.assertTrue(isinstance(getattr(system_user, name), TEXT))
Exemplo n.º 5
0
class IRedefinePermission(Interface):
    """Define a permission to replace another permission."""

    from_ = Permission(
        title=_u("Original permission"),
        description=_u("Original permission id to redefine."),
        required=True)

    to = Permission(
        title=_u("Substituted permission"),
        description=_u("Substituted permission id."),
        required=True)
Exemplo n.º 6
0
class IRequire(Interface):
    """Require a permission to access selected module attributes

    The given permission is required to access any names provided
    directly in the attributes attribute or any names defined by
    interfaces listed in the interface attribute.  
    """

    attributes = Tokens(
        title=_u("Attributes"),
        description=_u("The attributes to require permission for."),
        value_type = PythonIdentifier(),
        required=False)

    permission = Permission(
        title=_u("Permission ID"),
        description=_u("The id of the permission to require."))
Exemplo n.º 7
0
class IAllow(Interface):
    """Allow access to selected module attributes

    Access is unconditionally allowed to any names provided directly
    in the attributes attribute or to any names defined by
    interfaces listed in the interface attribute.
    """

    attributes = Tokens(
        title=_u("Attributes"),
        description=_u("The attributes to provide access to."),
        value_type = PythonIdentifier(),
        required=False)

    interface = Tokens(
        title=_u("Interface"),
        description=_u("Interfaces whos names to provide access to. Access "
                       "will be provided to all of the names defined by the "
                       "interface(s). Multiple interfaces can be supplied."),
        value_type = GlobalInterface(),
        required=False)
Exemplo n.º 8
0
class IPermissionDirective(Interface):
    """Define a new security object."""

    id = Id(
        title=_u("Id"),
        description=_u("Id as which this object will be known and used."),
        required=True)

    title = MessageID(
        title=_u("Title"),
        description=_u("Provides a title for the object."),
        required=True)

    description = MessageID(
        title=_u("Description"),
        description=_u("Provides a description for the object."),
        required=False)
Exemplo n.º 9
0
def PermissionIdsVocabulary(context=None):
    """A vocabulary of permission IDs.

    Term values are the permission ID strings except for 'zope.Public', which
    is the global permission CheckerPublic.

    Term titles are the permission ID strings except for 'zope.Public', which
    is shortened to 'Public'.

    Terms are sorted by title except for 'Public', which always appears as
    the first term.
    """
    terms = []
    has_public = False
    for name, permission in getUtilitiesFor(IPermission, context):
        if name == 'zope.Public':
            has_public = True
        else:
            terms.append(SimpleTerm(name, name, name))
    terms = sorted(terms, key=operator.attrgetter('title'))
    if has_public:
        terms.insert(0, SimpleTerm(CheckerPublic, 'zope.Public', _u('Public')))
    return SimpleVocabulary(terms)
Exemplo n.º 10
0
def PermissionIdsVocabulary(context=None):
    """A vocabulary of permission IDs.

    Term values are the permission ID strings except for 'zope.Public', which
    is the global permission CheckerPublic.

    Term titles are the permission ID strings except for 'zope.Public', which
    is shortened to 'Public'.

    Terms are sorted by title except for 'Public', which always appears as
    the first term.
    """
    terms = []
    has_public = False
    for name, permission in getUtilitiesFor(IPermission, context):
        if name == 'zope.Public':
            has_public = True
        else:
            terms.append(SimpleTerm(name, name, name))
    terms = sorted(terms, key=operator.attrgetter('title'))
    if has_public:
        terms.insert(0, SimpleTerm(CheckerPublic, 'zope.Public', _u('Public')))
    return SimpleVocabulary(terms)
Exemplo n.º 11
0
    object: object(),
    int: 65536,
    float: -1.4142,
    complex: -1.4142j,
    type(None): None,
    bytes: b'abc',
    bool: True,
    datetime.timedelta: datetime.timedelta(3),
    datetime.datetime: datetime.datetime(2003, 1, 1),
    datetime.date: datetime.date(2003, 1, 1),
    datetime.time: datetime.time(23, 58),
    Message: Message('message', domain='hello')
}

if PYTHON2:
    BasicTypes_examples[unicode] = _u('uabc')
    BasicTypes_examples[long] = long(65536)


class _Sequence(object): #pragma NO COVER
    def __len__(self): return 0
    def __getitem__(self, i): raise IndexError

_Declaration_checker = InterfaceChecker(
    IDeclaration,
    _implied=CheckerPublic,
    subscribe=CheckerPublic,
    unsubscribe=CheckerPublic,
    __call__=CheckerPublic,
    )
Exemplo n.º 12
0
class system_user(object):
    id = _u('zope.security.management.system_user')
    title = _u('System')
    description = _u('')
Exemplo n.º 13
0
 class IDummy(Interface):
     perm = zope.security.zcml.Permission(title=_u(''))
Exemplo n.º 14
0
def allPermissions(context=None):
    """Get the ids of all defined permissions
    """
    for id, permission in getUtilitiesFor(IPermission, context):
        if id != _u('zope.Public'):
            yield id
Exemplo n.º 15
0
 class IFoo(Interface):
     bar = Field(_u("Bar"), readonly=True)
Exemplo n.º 16
0
 class IFoo(Interface):
     bar = Field(_u("Bar"))
     baz = Field(_u("Baz"))
Exemplo n.º 17
0
    object: object(),
    int: 65536,
    float: -1.4142,
    complex: -1.4142j,
    type(None): None,
    bytes: b'abc',
    bool: True,
    datetime.timedelta: datetime.timedelta(3),
    datetime.datetime: datetime.datetime(2003, 1, 1),
    datetime.date: datetime.date(2003, 1, 1),
    datetime.time: datetime.time(23, 58),
    Message: Message('message', domain='hello')
}

if PYTHON2:
    BasicTypes_examples[unicode] = _u('uabc')
    BasicTypes_examples[long] = long(65536)


class _Sequence(object):  #pragma NO COVER
    def __len__(self):
        return 0

    def __getitem__(self, i):
        raise IndexError


_Declaration_checker = InterfaceChecker(
    IDeclaration,
    _implied=CheckerPublic,
    subscribe=CheckerPublic,
Exemplo n.º 18
0
def allPermissions(context=None):
    """Get the ids of all defined permissions
    """
    for id, permission in getUtilitiesFor(IPermission, context):
        if id != _u('zope.Public'):
            yield id