| # Gaudi Framework, version v23r0 |

Home |  | Generated: Mon Jan 30 2012

Classes | Functions | Variables

# 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' ]
| data ---------------------------------------------------------------------
tuple | log = logging.getLogger( 'PropertyProxy' )

## Function Documentation

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

Definition at line 30 of file PropertyProxy.py.

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

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.

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

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

Definition at line 348 of file PropertyProxy.py.

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

## Variable Documentation

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

data ---------------------------------------------------------------------

Definition at line 6 of file PropertyProxy.py.

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

Definition at line 13 of file PropertyProxy.py.

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines