2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
5 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # SALOME Container : implementation of container and engine for Kernel
25 # File : SALOME_Container.py
26 # Author : Paul RASCLE, EDF
30 ## @package SALOME_Container
31 # \brief python implementation of container interface for Kernel
39 from omniORB import CORBA, PortableServer
41 import Engines, Engines__POA
42 from SALOME_NamingServicePy import *
43 from SALOME_ComponentPy import *
46 from SALOME_utilities import *
47 from Utils_Identity import getShortHostName
48 from launchConfigureParser import verbose
50 #=============================================================================
52 #define an implementation of the container interface for embedding in Container implemented in C++
54 class SALOME_Container_i:
58 _naming_service = None
60 #-------------------------------------------------------------------------
62 def __init__(self ,containerName, containerIORStr):
63 MESSAGE( "SALOME_Container_i::__init__" )
64 self._orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
65 self._poa = self._orb.resolve_initial_references("RootPOA")
66 self._containerName = containerName
67 if verbose(): print "SALOME_Container.SALOME_Container_i : _containerName ",self._containerName
68 #self._naming_service = SALOME_NamingServicePy_i(self._orb)
69 self._container = self._orb.string_to_object(containerIORStr)
71 #-------------------------------------------------------------------------
73 def import_component(self, componentName):
74 MESSAGE( "SALOME_Container_i::import_component" )
77 if verbose(): print "try import ",componentName
78 __import__(componentName)
79 if verbose(): print "import ",componentName," successful"
82 ret=traceback.format_exc(10)
85 print "import ",componentName," not possible"
88 #-------------------------------------------------------------------------
90 def create_component_instance(self, componentName, instanceName, studyId):
91 MESSAGE( "SALOME_Container_i::create_component_instance" )
94 component=__import__(componentName)
95 factory=getattr(component,componentName)
96 comp_i=factory(self._orb,
103 MESSAGE( "SALOME_Container_i::create_component_instance : OK")
104 comp_o = comp_i._this()
105 comp_iors = self._orb.object_to_string(comp_o)
108 traceback.print_exc()
109 MESSAGE( "SALOME_Container_i::create_component_instance : NOT OK")
113 def create_pynode(self,nodeName,code):
115 node=SALOME_PyNode.PyNode_i(nodeName,code,self._poa)
116 id_o = self._poa.activate_object(node)
117 comp_o = self._poa.id_to_reference(id_o)
118 comp_iors = self._orb.object_to_string(comp_o)
121 exc_typ,exc_val,exc_fr=sys.exc_info()
122 l=traceback.format_exception(exc_typ,exc_val,exc_fr)