[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - RoleService.py:1.1.2.1

Jim Fulton jim@zope.com
Thu, 3 Jan 2002 14:13:37 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv13642

Added Files:
      Tag: Zope-3x-branch
	RoleService.py 
Log Message:
Added view component for managing role-permission settings

=== Added File Zope3/lib/python/Zope/App/Security/tests/RoleService.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""RoleService implementation for testing

Revision information: $Id: RoleService.py,v 1.1.2.1 2002/01/03 19:13:36 jim Exp $
"""

from Zope.App.Security.IRoleService import IRoleService
from Zope.App.Security.IRole import IRole

class Role:

    __implements__ = IRole

    def __init__(self, id, title): self._id, self._title = id, title
    def getId(self): return self._id
    def getTitle(self): return self._title
    def getDescription(self): return ''

class RoleService:

    __implements__ = IRoleService    

    def __init__(self, **kw):
        self._roles = r = {}
        for id, title in kw.items(): r[id]=Role(id, title) 

    # Implementation methods for interface
    # Zope.App.Security.IRoleService.

    def getRole(self, rid):
        '''See interface IRoleService'''
        return self._roles.get(rid)

    def getRoles(self):
        '''See interface IRoleService'''
        return self._roles.values()