I am defining a function in a python module acmelibrary.py:
and I invoke it like this:
NameError: cd
Workaround:
in all WLST scripts there is a variable WLS of type com.oracle.cie.domain.script.jython.WLScriptContext, and you have to pass it as a parameter to the createMailSession:
and in your acmelibrary.py you start with a
at this point your code can do
See also http://docs.oracle.com/cd/E15051_01/wls/docs103/config_scripting/using_WLST.html#wp1094333
def createMailSession(theMailSessionName, adminName, clusterName):
cd('/')
and I invoke it like this:
Much to my dismay, the cd('/') statement works perfectly when invoked in the main module, but not in the library:
from acmelibrary import createMailSession
createMailSession(theMailSessionName, adminName, clusterName)
NameError: cd
Workaround:
in all WLST scripts there is a variable WLS of type com.oracle.cie.domain.script.jython.WLScriptContext, and you have to pass it as a parameter to the createMailSession:
A more radical approach is to create a wl.py module:
def createMailSession(wls, theMailSessionName, adminName, clusterName):
wls.cd('/')
from weblogic.management.scripting.utils import WLSTUtil
import sys
origPrompt = sys.ps1
theInterpreter = WLSTUtil.ensureInterpreter();
WLSTUtil.ensureWLCtx(theInterpreter)
execfile(WLSTUtil.getWLSTScriptPath())
execfile(WLSTUtil.getOfflineWLSTScriptPath())
exec(WLSTUtil.getOfflineWLSTScriptForModule())
execfile(WLSTUtil.getWLSTCommonModulePath())
theInterpreter = None
sys.ps1 = origPrompt
modules = WLSTUtil.getWLSTModules()
for mods in modules:
execfile(mods.getAbsolutePath())
wlstPrompt = "false"
and in your acmelibrary.py you start with a
import wl
at this point your code can do
def createMailSession(theMailSessionName, adminName, clusterName):
wl.cd('/')
See also http://docs.oracle.com/cd/E15051_01/wls/docs103/config_scripting/using_WLST.html#wp1094333