Mucking with the calling scripts namespace (For a good reason, honest!)

From: Doug Rosser (da_rosser_at_yahoo.com)
Date: 08/02/04


Date: 2 Aug 2004 08:27:35 -0700

I'm writing a fairly complicated test framework and keeping
configuration data inside ini files that are parsed at runtime by the
ConfigParser module.

For example, there would be a section similar to the following

[servers]
server1:{'hostname':'alpha','os':'posix'}
server2:{'hostname':'beta','os':'win'}

[clients]
client1:{'hostname':'ichi','os':'posix'}
client2:{'hostname':'ni','os':'posix'}

As I read the configuration file, I don't actually create instances,
but use the data to check "what's out there" to make sure the physical
network environment has the bits and pieces required to run a
particular test. This is a sort of "go/no-go" resource check.

Assuming that everything is correct with the physical network
environment, I want my testers to be able to refer to these resources
in their python scripts by the names in the ini file, like so:

myTest.checkResources() # Read the config file and associate names
with real
                        # life instances

server1.doSomething() # Note how I have cleverly saved myself from
declaring
                        # "server1" because the module myTest has
inserted
                        # it into the right namespace :-)

Down to business: How do I write a module that can insert these names
into the calling script's namespace at runtime? Is this even possible
in Python?

da rosser
-- We are the music makers, and we are the dreamers of dreams --



Relevant Pages

  • Re: Jumpstart failed Solaris 10 9/10 release
    ... Provide Solaris Auto Registration Info: ... Oracle Solaris communicates configuration ... To send the configuration data anonymously, ... If using a proxy server, ...
    (SunManagers)
  • Re: What do REAL programmers do?
    ... the configuration will stay the same even if ... No INI files to bother with. ... manipulate configuration. ... "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ...
    (microsoft.public.vb.general.discussion)
  • Re: How to save data withought database ?
    ... > configuration and etc are in system registry. ... > or is it better to create database and stor this informations including ... you should not store too much data in the system registry. ... For language configurations and MRU file lists, INI files might be the ...
    (microsoft.public.dotnet.languages.vb)
  • RE: [Newbie] Saving a configuration file (in Xml?)
    ... > I need to store some configuration setting (basically int and float numbers, ... > 1)Save/Load a txt file with the configuration data. ... > 3)Save/Load a XML file. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Configuration data for a Windows Service
    ... The configuration data for each pluggable object will contain data related ... to modify the configuration for the hosting and pluggable objects. ... I'm pretty sure I want to store this information in XML configuration ...
    (microsoft.public.dotnet.framework)