1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : QAD_PyInterp_mono.cxx
8 // Author : Paul RASCLE, EDF
14 #include "QAD_PyInterp_mono.h"
15 #include "utilities.h"
18 * constructor : only one Python interpreter, shared within SALOME studies.
19 * calls initialize method defined in base class, which calls virtual methods
20 * initstate & initcontext redefined here.
22 QAD_PyInterp_mono::QAD_PyInterp_mono(): PyInterp_base()
27 QAD_PyInterp_mono::~QAD_PyInterp_mono()
33 * When SALOME uses mono Python interpreter feature,
34 * every study has its own context (dictionnary) but shares builtins
35 * and all the modules (sys, ...) with other studies.
36 * A module imported in a study is seen in another study (pros ans cons !).
39 void QAD_PyInterp_mono::initState()
41 salomeAcquireLock(); //acquire python global lock (one for all interpreters)
42 _tstate = PyThreadState_Get();
43 PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv
46 void QAD_PyInterp_mono::initContext()
48 _g = PyDict_New(); // create interpreter dictionnary context
49 PyObject *bimod = PyImport_ImportModule("__builtin__");
50 PyDict_SetItemString(_g, "__builtins__", bimod);