| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | Properties | Private Attributes | List of all members
GaudiKernel.PropertyProxy.PropertyProxy Class Reference
Inheritance diagram for GaudiKernel.PropertyProxy.PropertyProxy:
[legend]
Collaboration diagram for GaudiKernel.PropertyProxy.PropertyProxy:
[legend]

## Public Member Functions
def | __init__ (self, descr, docString=None, default=None)
def | setDefault (self, value)
def | getDefault (self)
def | fullPropertyName (self, obj)
def | __get__ (self, obj, type=None)
def | __set__ (self, obj, value)
def | __delete__ (self, obj)

## Public Attributes
| history
| descr

## Properties
| default = property( getDefault, setDefault )

## Private Attributes
| __doc__
| __default

## Detailed Description

Definition at line 62 of file PropertyProxy.py.

## Constructor & Destructor Documentation

def GaudiKernel.PropertyProxy.PropertyProxy.__init__ | ( |  | self,
|  |  | descr,
|  |  | docString = `None`,
|  |  | default = `None`
| ) |  |

Definition at line 63 of file PropertyProxy.py.

63 def __init__( self, descr, docString=None, default=None ):
64 self.history = {}
65 self.descr = descr
66 if docString:
67 self.__doc__ = docString
68 if default is not None:
69 self.default = default
70
71
GaudiKernel.PropertyProxy.PropertyProxy.history
history
Definition: PropertyProxy.py:64
GaudiKernel.PropertyProxy.PropertyProxy.descr
descr
Definition: PropertyProxy.py:65
GaudiKernel.PropertyProxy.PropertyProxy.default
default
Definition: PropertyProxy.py:78
GaudiKernel.PropertyProxy.PropertyProxy.__init__
def __init__(self, descr, docString=None, default=None)
Definition: PropertyProxy.py:63
GaudiKernel.PropertyProxy.PropertyProxy.__doc__
__doc__
Definition: PropertyProxy.py:67

## Member Function Documentation

def GaudiKernel.PropertyProxy.PropertyProxy.__delete__ | ( |  | self,
|  |  | obj
| ) |  |

Definition at line 145 of file PropertyProxy.py.

145 def __delete__( self, obj ):
146 if obj in self.history:
147 del self.history[ obj ]
148 self.descr.__delete__( obj )
149
150
151
GaudiKernel.PropertyProxy.PropertyProxy.history
history
Definition: PropertyProxy.py:64
GaudiKernel.PropertyProxy.PropertyProxy.__delete__
def __delete__(self, obj)
Definition: PropertyProxy.py:145

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

Definition at line 83 of file PropertyProxy.py.

83 def __get__( self, obj, type = None ):
84 try:
85 return self.descr.__get__( obj, type )
86 except AttributeError:
87 # special case for lists and dictionaries:
88 # allow default to work with on += and []
89 if self.__default.__class__ in [ list, dict ]:
90 self.descr.__set__( obj, self.__default.__class__(self.__default) )
91 return self.descr.__get__( obj, type )
92 else:
93 # for non lists (or dicts) return a reference to the default
94 #return self.__default
95 raise
96
GaudiKernel.PropertyProxy.PropertyProxy.__get__
def __get__(self, obj, type=None)
Definition: PropertyProxy.py:83
GaudiKernel.PropertyProxy.PropertyProxy.__default
__default
Definition: PropertyProxy.py:73

def GaudiKernel.PropertyProxy.PropertyProxy.__set__ | ( |  | self,
|  |  | obj,
|  |  | value
| ) |  |

Definition at line 97 of file PropertyProxy.py.

97 def __set__( self, obj, value ):
98 # check value/property compatibility if possible
99 proptype, allowcompat = None, False
100 if hasattr( self, 'default' ):
101 proptype = type(self.default)
102 if self.descr.__name__ == 'OutputLevel': # old-style compat for Btag
103 allowcompat = True
104 elif obj in self.history:
105 proptype = type( self.history[ obj ][ 0 ] )
106 allowcompat = True
107
108 # check if type known; allow special initializer for typed instances
109 # Do not perform the check for PropertyReference, should be delayed until
110 # binding (if ever done)
111 if proptype and proptype != type(None) and \
112 not derives_from(value, 'PropertyReference'):
113 try:
114 # check value itself
115 value = _isCompatible( proptype, value )
116
117 # check element in case of list
118 if proptype == list:
119 try:
120 oldvec = self.descr.__get__( obj, type )
121 if oldvec:
122 tpo = type(oldvec[0])
123 for v in value:
124 _isCompatible( tpo, v )
125 except AttributeError:
126 # value not yet set
127 pass
128 except ValueError, e:
129 if allowcompat:
130 log.error( 'inconsistent value types for %s.%s (%s)' %\
131 (obj.getName(),self.descr.__name__,str(e)) )
132 else:
133 raise
134
135 # allow a property to be set if we're in non-default mode, or if it
136 # simply hasn't been set before
137 if not obj._isInSetDefaults() or not obj in self.history:
138 # by convention, 'None' for default is used to designate objects setting
139 if hasattr( self, 'default' ) and self.default == None:
140 obj.__iadd__( value, self.descr ) # to establish hierarchy
141 else:
142 self.descr.__set__( obj, value )
143 self.history.setdefault( obj, [] ).append( value )
144
GaudiKernel.PropertyProxy.PropertyProxy.history
history
Definition: PropertyProxy.py:64
GaudiKernel.PropertyProxy.PropertyProxy.descr
descr
Definition: PropertyProxy.py:65
gaudirun.type
type
Definition: gaudirun.py:125
GaudiKernel.PropertyProxy.PropertyProxy.default
default
Definition: PropertyProxy.py:78
GaudiKernel.PropertyProxy.PropertyProxy.__set__
def __set__(self, obj, value)
Definition: PropertyProxy.py:97
GaudiKernel.PropertyProxy.derives_from
def derives_from(derived, base)
Definition: PropertyProxy.py:20
GaudiKernel.PropertyProxy._isCompatible
def _isCompatible(tp, value)
Definition: PropertyProxy.py:31

def GaudiKernel.PropertyProxy.PropertyProxy.fullPropertyName | ( |  | self,
|  |  | obj
| ) |  |

Definition at line 80 of file PropertyProxy.py.

80 def fullPropertyName( self, obj ):
81 return (obj.getJobOptName() or obj.getName()) + '.' + self.descr.__name__
82
GaudiKernel.PropertyProxy.PropertyProxy.fullPropertyName
def fullPropertyName(self, obj)
Definition: PropertyProxy.py:80

def GaudiKernel.PropertyProxy.PropertyProxy.getDefault | ( |  | self | ) |

Definition at line 75 of file PropertyProxy.py.

75 def getDefault( self ):
76 return self.__default
77
GaudiKernel.PropertyProxy.PropertyProxy.getDefault
def getDefault(self)
Definition: PropertyProxy.py:75
GaudiKernel.PropertyProxy.PropertyProxy.__default
__default
Definition: PropertyProxy.py:73

def GaudiKernel.PropertyProxy.PropertyProxy.setDefault | ( |  | self,
|  |  | value
| ) |  |

Definition at line 72 of file PropertyProxy.py.

72 def setDefault( self, value ):
73 self.__default = value
74
GaudiKernel.PropertyProxy.PropertyProxy.__default
__default
Definition: PropertyProxy.py:73
GaudiKernel.PropertyProxy.PropertyProxy.setDefault
def setDefault(self, value)
Definition: PropertyProxy.py:72

## Member Data Documentation

GaudiKernel.PropertyProxy.PropertyProxy.__default
| private

Definition at line 73 of file PropertyProxy.py.

GaudiKernel.PropertyProxy.PropertyProxy.__doc__
| private

Definition at line 67 of file PropertyProxy.py.

GaudiKernel.PropertyProxy.PropertyProxy.descr

Definition at line 65 of file PropertyProxy.py.

GaudiKernel.PropertyProxy.PropertyProxy.history

Definition at line 64 of file PropertyProxy.py.

## Property Documentation

GaudiKernel.PropertyProxy.PropertyProxy.default = property( getDefault, setDefault )
| static

Definition at line 78 of file PropertyProxy.py.

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

- GaudiKernel/python/GaudiKernel/PropertyProxy.py