Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Jython imports and wsadmin AdminControl object

106 views
Skip to first unread message

Markus Kolb

unread,
Aug 20, 2007, 6:56:18 AM8/20/07
to
Hi,

is it possible to use the AdminControl object in a Jython module?
It is available in the main-script but not in imported modules.
Do I've to add something in the scripts to access the AdminControl object in the modules?

Thx

Infyniti

unread,
Aug 20, 2007, 4:03:49 PM8/20/07
to
You should be declaring these objects globally in every module. For example if you want to use AdminTask and AdminConfig then declare them globally in every module.

global AdminTask, AdminConfig

Thanks
Anant

Markus Kolb

unread,
Aug 21, 2007, 2:48:53 AM8/21/07
to
I'm talking about Jython and not JACL language...

WASX7017E: Exception received while running file "/home/rpci182/bin/ebkWsadminProfile.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
File "<string>", line 76, in ?
File "/home/rpci182/bin/wsadmin.py/ebkUtils/ebkUtils.py", line 25, in showInfos
File "/home/rpci182/bin/wsadmin.py/ebkUtils/ebkUtils.py", line 57, in getCellid
NameError: AdminConfig


Related contents of ebkUtils.py:

global AdminApp, AdminConfig, AdminControl, AdminTask


def showInfos():
print "***** Willkommen im wsadmin *****"
cellid=getCellid()

def getCellid():
global AdminApp, AdminConfig, AdminControl, AdminTask
cellname=AdminConfig.showAttribute(AdminConfig.list("Cell"), "name")
varlist=AdminConfig.getid("/Cell:"+cellname+"/VariableMap:/")
entries=AdminConfig.show(varlist).split('[')[2].split(']')[0].split()


Brian S Paskin

unread,
Aug 21, 2007, 4:58:30 AM8/21/07
to

Markus Kolb

unread,
Aug 21, 2007, 7:15:15 AM8/21/07
to
Yes, thx, I know how to use it.
But my problem is that the object itself is not available in the modules (See below).
Another strange non-standard P/Jython thing is that there is no __main__ module available in wsadmin.
With __main__.PROPERTY you could access properties which were defined in the start-script. So I could access the AdminControl object with __main__.AdminControl.

Up to now I only know 2 solutions/workarounds:
1. I don't use the OO-style of importing modules/methods etc. but I use execfile(PYTHONFILE)
2. I use import and classes and each class instance needs AdminApp, AdminConfig, AdminControl, AdminApp as parameters so that the class knows these objects and can use them.

In P/Jython there are only module-wide globals. So I miss something how I can access the AdminControl object in modules. The standard way would be to use __main__ which is not available ;-(


-----

WASX7017E: Exception received while running file "/home/rpci182/bin/ebkWsadminProfile.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
File "<string>", line 76, in ?
File "/home/rpci182/bin/wsadmin.py/ebkUtils/ebkUtils.py", line 25, in showInfos
File "/home/rpci182/bin/wsadmin.py/ebkUtils/ebkUtils.py", line 57, in getCellid
NameError: AdminConfig


ebkWsadminProfile.py:

from ebkUtils.ebkUtils import *
showInfos()

Patrick Finnegan

unread,
Aug 22, 2007, 6:34:22 AM8/22/07
to
0 new messages