[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ConnectionService - ConnectionService.py:1.1 IConnectionAdding.py:1.1 IConnectionManager.py:1.1 __init__.py:1.1 configure.zcml:1.1

Stephan Richter srichter@cbu.edu
Mon, 24 Jun 2002 12:18:51 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ConnectionService
In directory cvs.zope.org:/tmp/cvs-serv17028/OFS/Services/ConnectionService

Added Files:
	ConnectionService.py IConnectionAdding.py 
	IConnectionManager.py __init__.py configure.zcml 
Log Message:
Initial RDBMS Connection Service...



=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/ConnectionService.py ===
##############################################################################
#
# Copyright (c) 2002 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.
# 
##############################################################################
"""$Id: ConnectionService.py,v 1.1 2002/06/24 16:18:50 srichter Exp $
"""

from Zope.ComponentArchitecture import getNextService
from IConnectionManager import IConnectionManager
from Persistence import PersistentMapping, Persistent

class ConnectionService(Persistent):
    
    __implements__ = IConnectionManager

    def __init__(self):
        self.__connections = PersistentMapping()

    # IContainer methods
    def __getitem__(self, key):
        """see interface Zope.App.OFS.Container.IContainer."""
        return self.__connections[key]

    def get(self, key, default=None):
        """see interface Zope.App.OFS.Container.IContainer."""        
        return self.__connections.get(key, default)

    def __contains__(self, key):
        """see interface Zope.App.OFS.Container.IContainer."""        
        return self.__connections.has_key(key)

    def keys(self):
        """see interface Zope.App.OFS.Container.IContainer."""        
        return self.__connections.keys()

    def values(self):
        """see interface Zope.App.OFS.Container.IContainer."""        
        return self.__connections.values()

    def items(self):
        """see interface Zope.App.OFS.Container.IContainer."""        
        return self.__connections.items()

    def __len__(self):
        """see interface Zope.App.OFS.Container.IContainer."""        
        return len(self.__connections)

    def setObject(self, key, object):
        """see interface Zope.App.OFS.Container.IContainer."""        
        self.__connections[key] = object
        return object

    def __delitem__(self, key):
        """see interface Zope.App.OFS.Container.IContainer."""        
        del self.__connections[key]

    # IConnectionService methods
    def getConnection(self, name):
        """see interface Zope.App.RDB.IConnectionService """
        return self[name]()
        
    def queryConnection(self, name, default):
        """see interface Zope.App.RDB.IConnectionService """        
        return self.get(name, default)()

    def getAvailableConnections(self):
        """Returns the connections known to this connection service"""
        # XXX, not yet
        # connections = self.keys()
        # return connections + \getNextService(self, "ConnectionService").getAvailableConnections()
    


=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/IConnectionAdding.py ===
##############################################################################
#
# Copyright (c) 2002 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.
# 
##############################################################################
"""XXX short summary goes here.

XXX longer description goes here.

$Id: IConnectionAdding.py,v 1.1 2002/06/24 16:18:50 srichter Exp $
"""

from Zope.App.OFS.Container.IAdding import IAdding

class IConnectionAdding(IAdding):
    pass





=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/IConnectionManager.py ===
##############################################################################
#
# Copyright (c) 2002 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.
# 
##############################################################################
"""
$Id: IConnectionManager.py,v 1.1 2002/06/24 16:18:50 srichter Exp $
"""
from Zope.App.OFS.Container.IContainer import IContainer
from Zope.App.RDB.IConnectionService import IConnectionService

class IConnectionManager(IContainer, IConnectionService):
    """TTW object that manages RDBMS connections"""

__doc__ = IConnectionManager.__doc__ + __doc__


=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/__init__.py ===
##############################################################################
#
# Copyright (c) 2002 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.
# 
##############################################################################


=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/configure.zcml ===
<zopeConfigure
   xmlns='http://namespaces.zope.org/zope'
   xmlns:browser='http://namespaces.zope.org/browser'

   xmlns:service='http://namespaces.zope.org/service'
>
  <content class=".ConnectionService.">

    <factory
        id="ConnectionService"
        permission="Zope.ManageServices"
        />

    <require
        permission="Zope.View"
        interface="Zope.App.RDB.IConnectionService." />
    <require
        permission="Zope.ManageServices"
        interface="Zope.App.OFS.Container.IContainer." />

  </content>

  <browser:menuItem menu="add_service" for="Zope.App.OFS.Container.IAdding."
     action="ConnectionService"  title="RDBMS Connection Service" />

  <include package=".Views" />

</zopeConfigure>