Lawrence D'Oliveiro wrote:
In message <mailman.1112.1244128369.8015.python-l...@python.org>, Allen Fowler wrote:

1) Do you use virtualpython?

No idea what that is.

2) How do you load the modules in your lib directory?

At the beginning of my scripts, I have a sequence like

    test_mode = False # True for testing, False for production

    if test_mode :
        home_dir = "/home/shop-test"
    else :
        home_dir = "/home/shop"
    #end if

    sys.path.append(home_dir + "/lib")

    import common
    [etc]

I have an installation script that looks for that "test_mode = True/False" assignment and edits it accordingly. That flag is used to select the top- level directory (as above) as well as the database name, etc. This allows me to run two complete parallel sets of code and data, so I can mess around with the testing version without impacting the production system.

3) How do you reference your configuration directives from within your
modules and CGI/daemon scripts?

For my last project using the above system, I used XML as the config file format.


Rather than editing the source files at install time, consider just using an environment variable in your testing environment, which would be missing in production environment. Each command shell has its own set of environment variables, so this would make testing pretty easy, without the risk of things getting out of synch. Alternatively, if the script is located in a fixed place, relative to the home directory, just do some manipulation of the __file__ string.




--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to