[Zope-CVS] CVS: Products/AdaptableStorage/gateway_sql - SQLSecurityAttributes.py:1.1 public.py:1.5

Shane Hathaway shane@zope.com
Sat, 1 Mar 2003 15:43:33 -0500


Update of /cvs-repository/Products/AdaptableStorage/gateway_sql
In directory cvs.zope.org:/tmp/cvs-serv29278/gateway_sql

Modified Files:
	public.py 
Added Files:
	SQLSecurityAttributes.py 
Log Message:
- Added SecurityAttributes, FSSecurityAttributes, and
SQLSecurityAttributes.  These classes store Zope 2 role names, local
roles, executable ownership, permission mappings, and proxy roles.
(Until now, all of this ended up in the remainder pickle.)

- Added a second abstract object mapper to Zope2Mapper.  The "base"
mapper has no properties aspect, while the "base_p" mapper does.  This
made Zope2FS and Zope2SQL a little cleaner, since they don't have to
remove the properties aspect.

- Added corresponding unit tests.


=== Added File Products/AdaptableStorage/gateway_sql/SQLSecurityAttributes.py ===
##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################
"""SQL security attribute storage

$Id: SQLSecurityAttributes.py,v 1.1 2003/03/01 20:43:00 shane Exp $
"""

from mapper_public import IGateway, RowSequenceSchema

from SQLGatewayBase import SQLGatewayBase


class SQLSecurityAttributes (SQLGatewayBase):

    __implements__ = IGateway

    schema = RowSequenceSchema()
    schema.addField('declaration_type', 'string')
    schema.addField('role', 'string')
    schema.addField('permission', 'string')
    schema.addField('username', 'string')

    table_base_name = 'security'

    checkexist_sql = '''SELECT key FROM %(table)s WHERE key = 0'''

    create_sql = '''CREATE TABLE %(table)s (
    key int,
    declaration_type character varying(255),
    role character varying(255),
    permission character varying(255),
    username character varying(255)
    )'''

    read_sql = '''SELECT declaration_type, role, permission, username
    from %(table)s WHERE key = %(key)s'''

    insert_sql = '''INSERT INTO %(table)s
    (key, declaration_type, role, permission, username)
    VALUES (%(key)s, %(declaration_type)s, %(role)s,
    %(permission)s, %(username)s)'''

    delete_sql = '''DELETE FROM %(table)s
    WHERE key = %(key)s'''


    def getSchema(self):
        return self.schema

    def load(self, event):
        key = int(event.getKey())
        items = self.execute(self.read_sql, 1, key=key)
        items.sort()
        return items, tuple(items)

    def store(self, event, state):
        key = int(event.getKey())
        items = self.execute(self.read_sql, 1, key=key)
        items.sort()
        state = list(state)
        state.sort()
        if state != items:
            self.execute(self.delete_sql, key=key)
            for row in state:
                self.execute(
                    self.insert_sql, key=key, declaration_type=row[0],
                    role=row[1], permission=row[2], username=row[3])
        return tuple(state)



=== Products/AdaptableStorage/gateway_sql/public.py 1.4 => 1.5 ===
--- Products/AdaptableStorage/gateway_sql/public.py:1.4	Tue Jan  7 00:07:36 2003
+++ Products/AdaptableStorage/gateway_sql/public.py	Sat Mar  1 15:43:00 2003
@@ -25,4 +25,5 @@
 from SQLObjectData import SQLObjectData
 from SQLProperties import SQLProperties
 from SQLRemainder import SQLRemainder
+from SQLSecurityAttributes import SQLSecurityAttributes
 from SQLUserList import SQLUserList