Brandon wrote:
Peter,

You're correct about the bug.  I did need a 'self' parm...  I was just
winging the example because the actual code is pretty large.  I'm using
google groups for my posting and it didn't carry spaces through (I did
use spaces and not tabs).

The "fix" or workaround was to import __builtin__ and add the
AdminConfig reference there in configure_server_foo.py as follows:

import __builtin__
__builtin__.AdminConfig = AdminConfig

As for the indentations, substitute ~ with a space.

Hopefully, a bug free and "indented" version.  :)

#jdbc.py
class DataSource:
~~~def __init__(self, servername):
~~~~~~self.servername = servername

~~~def create(self, name, connectionInfo, etc):
~~~~~~#Call the IBM supplied WebSphere config object
~~~~~~AdminConfig.create('DataSource')


Is there any particular reason DataSource can't be modified to accept a reference to the AdminConfig as a constructor argument? Or as a class attribute?


Alternatively, here's another trick to 'nicely' set a module global from outside a module:

#jdbc.py
def setAdminConfig(adm_cfg):
  global AdminConfig
  AdminConfig = adm_cfg

However, if you would prefer not to alter jdbc.py, consider trying:

import jdbc
jdbc.AdminConfig = AdminConfig


Global variables are bad karma to start with, and monkeying with __builtin__ is even worse :)


Cheers,
Nick.

--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
            http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to