コード例 #1
0
ファイル: zcml.py プロジェクト: vedantc98/Plone-test
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)
コード例 #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)
コード例 #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))
コード例 #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))
コード例 #5
0
ファイル: zcml.py プロジェクト: vedantc98/Plone-test
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)
コード例 #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."))
コード例 #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)
コード例 #8
0
ファイル: zcml.py プロジェクト: vedantc98/Plone-test
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)
コード例 #9
0
ファイル: permission.py プロジェクト: vedantc98/Plone-test
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)
コード例 #10
0
ファイル: permission.py プロジェクト: SalesSeek/zope.security
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)
コード例 #11
0
ファイル: checker.py プロジェクト: jean/zope.security
    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,
    )
コード例 #12
0
class system_user(object):
    id = _u('zope.security.management.system_user')
    title = _u('System')
    description = _u('')
コード例 #13
0
 class IDummy(Interface):
     perm = zope.security.zcml.Permission(title=_u(''))
コード例 #14
0
ファイル: permission.py プロジェクト: vedantc98/Plone-test
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
コード例 #15
0
 class IFoo(Interface):
     bar = Field(_u("Bar"), readonly=True)
コード例 #16
0
 class IFoo(Interface):
     bar = Field(_u("Bar"))
     baz = Field(_u("Baz"))
コード例 #17
0
ファイル: checker.py プロジェクト: vedantc98/Plone-test
    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,
コード例 #18
0
ファイル: permission.py プロジェクト: SalesSeek/zope.security
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