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

# Source Code for Package Products.ZenUtils

     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  from Products.CMFCore.DirectoryView import registerDirectory
    14  registerDirectory('js', globals())
    15
    16  # import any monkey patches that may be necessary
    17  from patches import pasmonkey
    18  from patches import dirviewmonkey
    19  from Products.ZenUtils.Utils import unused
    20  unused(pasmonkey, dirviewmonkey)
    21
    22  from Products.ZenUtils.MultiPathIndex import MultiPathIndex , \
    23                                               manage_addMultiPathIndex, \
    24                                               manage_addMultiPathIndexForm
    25
    26 -def initialize(context):
    27      context.registerClass(
    28          MultiPathIndex,
    29          permission='Add Pluggable Index',
    30          constructors=(manage_addMultiPathIndexForm, manage_addMultiPathIndex),
    31          #icon="www/index.gif",
    32          visibility=None)
    33      # Initialize the MySQL talkingz
    34      app = context._ProductContext__app
    35      try:
    36          zem = app.zport.dmd.ZenEventManager
    37      except AttributeError, e:
    38          pass
    39
    40 -def safeTuple(arg):
    41      """
    42      >>> safeTuple(["foo", "blam"])
    43      ('foo', 'blam')
    44      >>> safeTuple([])
    45      ()
    46      >>> safeTuple(None)
    47      ()
    48      >>> safeTuple("foo")
    49      ('foo',)
    50      """
    51      if arg is not None:
    52          return tuple(arg) if hasattr(arg, '__iter__') else (arg,)
    53      else:
    54          return ()
    55