Package Products :: Package ZenRelations |
[hide private]
[frames] | no frames]

# Source Code for Package Products.ZenRelations

     1  ###########################################################################
     2  #
     3  # This program is part of Zenoss Core, an open source monitoring platform.
     4  # Copyright (C) 2007, Zenoss Inc.
     5  #
     6  # This program is free software; you can redistribute it and/or modify it
     7  # under the terms of the GNU General Public License version 2 or (at your
     8  # option) any later version as published by the Free Software Foundation.
     9  #
    10  # For complete information please visit: http://www.zenoss.com/oss/
    11  #
    12  ###########################################################################
    13  __doc__="""__init__
    14
    15  Initialize the RelationshipManager Product
    16
    17  $Id: __init__.py,v 1.9 2002/12/06 14:25:57 edahl Exp $"""
    18
    19  __version__ = "$Revision: 1.9 $"[11:-2]
    20
    21  import logging
    22
    23  from RelationshipManager import RelationshipManager, addRelationshipManager, \
    24                                  manage_addRelationshipManager
    25  from ToOneRelationship import ToOneRelationship, addToOneRelationship, \
    26                                  manage_addToOneRelationship
    27  from ToManyRelationship import ToManyRelationship, addToManyRelationship, \
    28                                  manage_addToManyRelationship
    29  from ToManyContRelationship import ToManyContRelationship, \
    30                                  addToManyContRelationship, \
    31                                  manage_addToManyContRelationship
    32  from Products.ZenRelations.ZenPropertyManager import setDescriptors
    33
    34  log = logging.getLogger("zen.ZenRelations")
    35
    36 -class ZODBConnectionError(Exception):
    37      pass
    38
    39 -def initialize(registrar):
    40      registrar.registerClass(
    41          RelationshipManager,
    42          constructors = (addRelationshipManager, manage_addRelationshipManager))
    43      registrar.registerBaseClass(RelationshipManager)
    44      registrar.registerClass(
    45          ToOneRelationship,
    46          constructors = (addToOneRelationship, manage_addToOneRelationship),
    47          icon = 'www/ToOneRelationship_icon.gif')
    48      registrar.registerClass(
    49          ToManyRelationship,
    50          constructors = (addToManyRelationship, manage_addToManyRelationship),
    51          icon = 'www/ToManyRelationship_icon.gif')
    52      registrar.registerClass(
    53          ToManyContRelationship,
    54          constructors = (addToManyContRelationship,
    55                          manage_addToManyContRelationship),
    56          icon = 'www/ToManyContRelationship_icon.gif')
    57      app = registrar._ProductContext__app
    58      if app is None:
    59          log.error("Could not connect to the zodb.")
    60          raise ZODBConnectionError("registered app is None")
    61
    62      # during the execution of runtests, zport may not be set
    63      # swallow that exception until root cause of this is discovered
    64      try:
    65          zport = app.zport
    66          dmd = zport.dmd
    67      except AttributeError as ex:
    68          log.debug("Problem with zport or dmd attribute on app: %r" % ex)
    69      else:
    70          try:
    71              setDescriptors(dmd.propertyTransformers)
    72          except Exception, e:
    73              args = (e.__class__.__name__, e)
    74              log.info("Unable to set property descriptors: %s: %s", *args)
    75