Commits

Anonymous committed f6ffb21

finalize migration of StoreGate's python bindings to Control/StoreGateBindings

Comments (0)

Files changed (4)

+2007-12-14  Sebastien Binet  <binet@lblbox>
+
+	* tagging StoreGateBindings-00-00-01
+	* finalize migration of StoreGate's python bindings to StoreGateBindings
+	* A python/Bindings.py
+	* M python/__init__.py
+	* M src/StoreGatePyExt.cxx
+
 2007-12-13  Sebastien Binet  <binet@lblbox>
 
 	* tagging StoreGateBindings-00-00-00

python/Bindings.py

+# @file: StoreGateBindings/python/Bindings.py
+# @author: Wim Lavrijsen <WLavrijsen@lbl.gov>
+# @author: Sebastien Binet <binet@cern.ch>
+
+### data
+__version__ = "$Revision: 1.1 $"
+__author__  = """
+Wim Lavrijsen (WLavrijsen@lbl.gov),
+Sebastien Binet (binet@cern.ch)
+"""
+
+### pythonizations for StoreGateSvc
+def _setup():
+    import PyCintex
+    # StoreGate bindings from dictionary
+    PyCintex.loadDictionary( "libStoreGateBindingsDict" )
+
+    # make sure the global C++ namespace has been created
+    gbl = PyCintex.makeNamespace('')
+    
+    global py_retrieve
+    py_retrieve = PyCintex.gbl.AthenaInternal.retrieveObjectFromStore
+
+    global py_record
+    py_record   = PyCintex.gbl.AthenaInternal.recordObjectToStore
+
+    # retrieve the StoreGateSvc class
+    global StoreGate, StoreGateSvc
+    StoreGateSvc = PyCintex.gbl.StoreGateSvc
+    StoreGate    = PyCintex.gbl.StoreGate
+
+    # add specialized retrieve method
+    def retrieve( self, klass, key = None ):
+        ptr = PyCintex.libPyROOT.MakeNullPointer( klass )
+        py_retrieve( self, klass, key, ptr )
+        return ptr
+    StoreGateSvc.retrieve = retrieve
+
+    # add specialized record method
+    def record( self, obj, key ):
+        py_record( self, obj, key )
+        return
+    StoreGateSvc.record = record
+
+    # make dump print, rather than return string
+    def dump( self ):
+        print self.__class__._dump( self )
+    StoreGateSvc._dump = StoreGateSvc.dump
+    StoreGateSvc.dump  = dump
+
+    # allow the use of the pythonized properties interface
+    def __getattr__( self, attr ):
+        try:                from GaudiPython.Bindings import iProperty
+        except ImportError: from gaudimodule          import iProperty
+        return getattr( iProperty("StoreGateSvc", self), attr )
+
+    def __setattr__( self, attr, value ):
+        try:                from GaudiPython.Bindings import iProperty
+        except ImportError: from gaudimodule          import iProperty
+        return setattr( iProperty("StoreGateSvc", self), attr, value )
+
+    StoreGateSvc.__getattr__ = __getattr__
+    StoreGateSvc.__setattr__ = __setattr__
+
+    return
+
+## execute method at module import
+_setup()
+
+## clean-up
+del _setup

python/__init__.py

 ## hook for the StoreGateBindings py-module
+# @file: StoreGateBindings/python/__init__.py
+# @author: Sebastien Binet <binet@cern.ch>
+
+__version__ = '$Revision: 1.2 $'
+__author__  = "Sebastien Binet <binet@cern.ch>"
+
+__all__ = [ 'Bindings' ]

src/StoreGatePyExt.cxx

 #define PYTHON_INC "Python.h"
 #include PYTHON_INC
 
-#include "StoreGate/StoreGateDict.h"
+#include "StoreGateBindingsDict.h"
 #include "SGTools/DataBucketBase.h"
 #include "GaudiKernel/Bootstrap.h"
 #include "GaudiKernel/DataObject.h"