Newbie namespace question
bcarlso at gmail.com
bcarlso at gmail.com
Wed Dec 22 10:28:28 EST 2004
Here's my situation, I've created some scripts to configure WebSphere
and the WAS scripting engine assigns the variable AdminConfig to a Java
object. I have created classes that wrap the AdminConfig settings,
simplifying the interface for those who want to script their server
installs.
At the command line, I pass the main script in and AdminConfig is
automatically assigned and placed in the global namespace and control
is passed to the main script.
Therefore...
#configure_server_foo.py
from jdbc import DataSource
print globals()["AdminConfig"] # Will print com.ibm.yada.yada.yada
# Create a couple of data sources
ds = DataSource("ServerName")
ds.create("dsname1", "connectionInfo", "etc")
ds.create("dsname2", "connectionInfo", "etc")
Now, in jdbc.py I have
#jdbc.py
class DataSource:
def __init__(self, servername):
self.servername = servername
def create(name, connectionInfo, etc):
#Call the IBM supplied WebSphere config object
AdminConfig.create('DataSource')
Run it and get a name error, which, makes sense.
If I try to use the standard import solution as deelan suggests I have
a circular reference on the imports and I get an error that it can't
import class DataSource (presumbably because it hasn't gotten far
enough through jdbc.py to realize that there's a DataSource class
defined.
Any insight would be greatly appreciated, and thanks to both deelan and
Steve for your help.
More information about the Python-list
mailing list