Package Products :: Package ZenUtils :: Module ZodbFactory |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenUtils.ZodbFactory

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2011, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     7  #
     8  ##############################################################################
     9
    10
    11  __doc__="""ZodbConnection
    12  """
    13  from Products.ZenUtils.GlobalConfig import globalConfToDict
    14  from zope.interface import Interface
    15  from zope.interface import implements
    16  from zope.component import queryUtility
    17
    18 -class IZodbFactoryLookup(Interface):
    19 -    def get(name=None):
    20          """Return the a ZODB connection Factory by name or look up in global.conf."""
    21
    22 -class ZodbFactoryLookup(object):
    23      implements(IZodbFactoryLookup)
    24
    25 -    def get(self, name=None):
    26          """Return the ZODB connection factory by name or look up in global.conf."""
    27          if name is None:
    28              settings = globalConfToDict()
    29              name = settings.get('zodb-db-type', 'mysql')
    30          connectionFactory = queryUtility(IZodbFactory, name)
    31          return connectionFactory
    32
    33
    34 -class IZodbFactory(Interface):
    35
    36 -    def getZopeZodbConf():
    37          """Return a zope.conf style stanza for the zodb connection."""
    38
    39 -    def getZopeZodbSessionConf():
    40          """Return a zope.conf style stanza for the zodb_session connection."""
    41
    42 -    def getConnection(**kwargs):
    43          """Return a ZODB connection."""
    44
    45 -    def buildOptions(parser):
    46          """basic command line options associated with zodb connections"""
    47