Gaudi Framework, version v23r0

Home   Generated: Mon Jan 30 2012
Public Member Functions | Public Attributes | Properties | Private Attributes

PropertyProxy::PropertyProxy Class Reference

Inheritance diagram for PropertyProxy::PropertyProxy:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def setDefault
def getDefault
def fullPropertyName
def __get__
def __set__
def __delete__

Public Attributes

 history
 descr

Properties

 default = property( getDefault, setDefault )

Private Attributes

 __doc__
 __default

Detailed Description

Definition at line 61 of file PropertyProxy.py.


Constructor & Destructor Documentation

def PropertyProxy::PropertyProxy::__init__ (   self,
  descr,
  docString = None,
  default = None 
)

Reimplemented in PropertyProxy::GaudiHandlePropertyProxy, and PropertyProxy::GaudiHandleArrayPropertyProxy.

Definition at line 62 of file PropertyProxy.py.

00063                                                              :
00064         self.history = {}
00065         self.descr   = descr
00066         if docString:
00067             self.__doc__ = docString
00068         if default is not None:
00069             self.default = default
00070 


Member Function Documentation

def PropertyProxy::PropertyProxy::__delete__ (   self,
  obj 
)

Definition at line 144 of file PropertyProxy.py.

00145                                :
00146         if obj in self.history:
00147             del self.history[ obj ]
00148         self.descr.__delete__( obj )
00149 
00150 

def PropertyProxy::PropertyProxy::__get__ (   self,
  obj,
  type = None 
)

Reimplemented in PropertyProxy::GaudiHandlePropertyProxyBase.

Definition at line 82 of file PropertyProxy.py.

00083                                          :
00084         try:
00085             return self.descr.__get__( obj, type )
00086         except AttributeError:
00087             # special case for lists and dictionaries:
00088             # allow default to work with on += and []
00089             if self.__default.__class__ in [ list, dict ]:
00090                 self.descr.__set__( obj, self.__default.__class__(self.__default) )
00091                 return self.descr.__get__( obj, type )
00092             else:
00093                 # for non lists (or dicts) return a reference to the default
00094                 #return self.__default
00095                 raise

def PropertyProxy::PropertyProxy::__set__ (   self,
  obj,
  value 
)

Reimplemented in PropertyProxy::GaudiHandlePropertyProxyBase.

Definition at line 96 of file PropertyProxy.py.

00097                                    :
00098      # check value/property compatibility if possible
00099         proptype, allowcompat = None, False
00100         if hasattr( self, 'default' ):
00101             proptype = type(self.default)
00102             if self.descr.__name__ == 'OutputLevel':      # old-style compat for Btag
00103                 allowcompat = True
00104         elif obj in self.history:
00105             proptype = type( self.history[ obj ][ 0 ] )
00106             allowcompat = True
00107 
00108      # check if type known; allow special initializer for typed instances
00109         # Do not perform the check for PropertyReference, should be delayed until
00110         # binding (if ever done)
00111         if proptype and proptype != type(None) and \
00112                         not derives_from(value, 'PropertyReference'):
00113             try:
00114              # check value itself
00115                 value = _isCompatible( proptype, value )
00116 
00117              # check element in case of list
00118                 if proptype == list:
00119                     try:
00120                         oldvec = self.descr.__get__( obj, type )
00121                         if oldvec:
00122                             tpo = type(oldvec[0])
00123                             for v in value:
00124                                 _isCompatible( tpo, v )
00125                     except AttributeError:
00126                      # value not yet set
00127                         pass
00128             except ValueError, e:
00129                 if allowcompat:
00130                     log.error( 'inconsistent value types for %s.%s (%s)' %\
00131                                (obj.getName(),self.descr.__name__,str(e)) )
00132                 else:
00133                     raise
00134 
00135      # allow a property to be set if we're in non-default mode, or if it
00136      # simply hasn't been set before
00137         if not obj._isInSetDefaults() or not obj in self.history:
00138         # by convention, 'None' for default is used to designate objects setting
00139             if hasattr( self, 'default' ) and self.default == None:
00140                 obj.__iadd__( value, self.descr )     # to establish hierarchy
00141             else:
00142                 self.descr.__set__( obj, value )
00143             self.history.setdefault( obj, [] ).append( value )

def PropertyProxy::PropertyProxy::fullPropertyName (   self,
  obj 
)

Definition at line 79 of file PropertyProxy.py.

00080                                      :
00081         return (obj.getJobOptName() or obj.getName()) + '.' + self.descr.__name__

def PropertyProxy::PropertyProxy::getDefault (   self )

Definition at line 74 of file PropertyProxy.py.

00075                           :
00076         return self.__default

def PropertyProxy::PropertyProxy::setDefault (   self,
  value 
)

Definition at line 71 of file PropertyProxy.py.

00072                                  :
00073         self.__default = value


Member Data Documentation

Definition at line 71 of file PropertyProxy.py.

Definition at line 62 of file PropertyProxy.py.

Definition at line 62 of file PropertyProxy.py.

Definition at line 62 of file PropertyProxy.py.


Property Documentation

PropertyProxy::PropertyProxy::default = property( getDefault, setDefault ) [static]

Definition at line 77 of file PropertyProxy.py.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Jan 30 2012 13:53:36 for Gaudi Framework, version v23r0 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004