| # Gaudi Framework, version v21r9 |

Home |  | Generated: 3 May 2010

# PropertyProxy::PropertyProxy Class Reference

Inheritance diagram for PropertyProxy::PropertyProxy:

[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
| default
## Static Public Attributes
tuple | default = property( getDefault, setDefault )
## Private Attributes
| __doc__
| __default

## Detailed Description

Definition at line 61 of file PropertyProxy.py.

## Member Function 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.

    00062                                                              :
    00063         self.history = {}
    00064         self.descr   = descr
    00065         if docString:
    00066             self.__doc__ = docString
    00067         if default is not None:
    00068             self.default = default
    00069
    00070
        def setDefault( self, value ):

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

Definition at line 71 of file PropertyProxy.py.

    00071                                  :
    00072         self.__default = value
    00073
        def getDefault( self ):

def PropertyProxy::PropertyProxy::getDefault | ( |  | self | ) |

Definition at line 74 of file PropertyProxy.py.

    00074                           :
    00075         return self.__default
    00076
        default = property( getDefault, setDefault )

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

Definition at line 79 of file PropertyProxy.py.

    00079                                      :
    00080         return (obj.getJobOptName() or obj.getName()) + '.' + self.descr.__name__
    00081
        def __get__( self, obj, type = None ):

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

Reimplemented in PropertyProxy::GaudiHandlePropertyProxyBase.

Definition at line 82 of file PropertyProxy.py.

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

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

Reimplemented in PropertyProxy::GaudiHandlePropertyProxyBase.

Definition at line 96 of file PropertyProxy.py.

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

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

Definition at line 144 of file PropertyProxy.py.

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

## Member Data Documentation

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

Definition at line 77 of file PropertyProxy.py.

PropertyProxy::PropertyProxy::history

Definition at line 63 of file PropertyProxy.py.

PropertyProxy::PropertyProxy::descr

Definition at line 64 of file PropertyProxy.py.

PropertyProxy::PropertyProxy::__doc__`[private]`

Definition at line 66 of file PropertyProxy.py.

PropertyProxy::PropertyProxy::default

Definition at line 68 of file PropertyProxy.py.

PropertyProxy::PropertyProxy::__default`[private]`

Definition at line 72 of file PropertyProxy.py.

The documentation for this class was generated from the following file:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r9/GaudiKernel/python/GaudiKernel/PropertyProxy.py