Question

when using WLST, I encounter several problems. We only use Solaris or Linux for our servers, so please remeber this when answering.

1: where should I place common modules for WLST that won't have anything to do with internal WLST-functions(option parsing, logging, output, ...) 1.1: I have written a few of my own, to account for the lack of existing within Jython 2.1 supplied by Oracle.

2: How can I include modules that use WLST internal functions so that they work, and don't lose their information(connect in a module doesn't stay connected when back in the main program).

Greetings

Was it helpful?

Solution

For #1 I am able to include library .py files in the same directory as the target script by adding the current path to sys.path. For instance, if I have a file functions.py, I would use this code:

import os, sys
sys.path.append(os.path.dirname(os.path.abspath(inspect.getsourcefile(lambda:(True)))))
import functions

I'm not sure if adding to sys.path is the Pythonic way of doing things, but it gets the job done and WLST is pretty "Wild West" as well.

If you're stuck using an older version of Weblogic like 10.x (and possibly 11g?), that embeds Python 2.1, you'll find that it doesn't have many now-standard libraries including the inspect library. You'll have to use sys.argv[0] instead of os.path.abspath(inspect.getsourcefile(lambda:(True))).

OTHER TIPS

For #1, I follow Ed Griebel's approach to append to the sys.path. To support older versions, I leverage the sys.argv[0] variable.

For #2, if you're doing an "import wlstModule" in your module, then in the main script I found you need to bypass the internal WLST functions provided and instead use the ones from wlstModule. Simply add the same "import wlstModule" within your main script then change all of your calls to use the imported wlstModule. For example, in your main script use calls like "wlstModule.cd()", "wlstModule.cmo()", and "wlstModule.set()", not "cd()", "cmo()", and "set()".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top