| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# PropertyProxy Namespace Reference

## Classes
class | PropertyProxy
class | GaudiHandlePropertyProxyBase
class | GaudiHandlePropertyProxy
class | GaudiHandleArrayPropertyProxy
## Functions
def | derives_from
def | _isCompatible
def | PropertyProxyFactory
## Variables
list | __all__ = [ 'PropertyProxy', 'GaudiHandlePropertyProxy', 'GaudiHandleArrayPropertyProxy' ]
tuple | log = logging.getLogger( 'PropertyProxy' )

## Function Documentation

def PropertyProxy::_isCompatible | ( |  | tp,
|  |  | value |
| ) |  |  | `[private]`

Definition at line 30 of file PropertyProxy.py.

    00030                               :
    00031     errmsg = "received an instance of %s, but %s expected" % (type(value),tp)
    00032
    00033     if derives_from(value, 'PropertyReference'):
    00034         # TODO: implement type checking for references
    00035         return value # references are valid
    00036     if ( tp is str ):
    00037         if ( type(value) is str ) or derives_from(value, 'Configurable'):
    00038             # we can set string properties only from strings or configurables
    00039             return value
    00040         else:
    00041             raise ValueError( errmsg )
    00042     elif ( tp in [ list, tuple, dict ] ):
    00043         if ( type(value) is tp ):
    00044             # We need to check that the types match for lists, tuples and
    00045             # dictionaries (bug #34769).
    00046             return value
    00047         else:
    00048             raise ValueError( errmsg )
    00049     elif derives_from(tp, 'Configurable'):
    00050         return value
    00051     else:
    00052         # all other types: accept if conversion allowed
    00053         try:
    00054             dummy = tp( value )
    00055         except (TypeError,ValueError):
    00056             raise ValueError( errmsg )
    00057
    00058     return dummy         # in case of e.g. classes with __int__, __iter__, etc. implemented
    00059
    00060
    class PropertyProxy( object ):

def PropertyProxy::derives_from | ( |  | derived,
|  |  | base |
| ) |  |  |

    A string version of isinstance().
    <derived> is either an object instance, or a type
    <base>    is a string containing the name of the base class (or <derived> class)

Definition at line 19 of file PropertyProxy.py.

    00019                               :
    00020     """A string version of isinstance().
    00021     <derived> is either an object instance, or a type
    00022     <base>    is a string containing the name of the base class (or <derived> class)"""
    00023     if not isinstance(derived,type): derived=type(derived)
    00024     if derived.__name__ == base: return True
    00025     for b in derived.__bases__:
    00026         if derives_from(b,base): return True
    00027
    00028     return False
    00029
    def _isCompatible( tp, value ):

def PropertyProxy::PropertyProxyFactory | ( |  | descr,
|  |  | doc,
|  |  | default |
| ) |  |  |

Definition at line 348 of file PropertyProxy.py.

    00348                                                :
    00349 #   print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
    00350     if isinstance(default,GaudiHandleArray):
    00351         return GaudiHandleArrayPropertyProxy( descr, doc, default )
    00352
    00353     if isinstance(default,GaudiHandle):
    00354         return GaudiHandlePropertyProxy( descr, doc, default )
    00355
    00356     return PropertyProxy( descr, doc, default )
        return PropertyProxy( descr, doc, default )

## Variable Documentation

list PropertyProxy::__all__ = [ 'PropertyProxy', 'GaudiHandlePropertyProxy', 'GaudiHandleArrayPropertyProxy' ]

Definition at line 6 of file PropertyProxy.py.

tuple PropertyProxy::log = logging.getLogger( 'PropertyProxy' )

Definition at line 13 of file PropertyProxy.py.