durusmail: quixote-users: dynamic path to import publisher factory
dynamic path to import publisher factory
2005-09-16
2005-09-16
dynamic path to import publisher factory
mario ruggier
2005-09-16
Hi,

imagine several packages for the same application, installed
simultaneously on the same machine. These can be for example a recent
stable/demo version, and a bleeding edge dev version. I want to be able
to run them concurrently, but independently. To run with either
simple_server or scgi_server, I am executing the respective python
scripts as new processes, that implies that if I adjust os.path in the
calling process, I cannot pass that env info to the child process. Or
can I?

Looking at the code, I wonder whether it is (a) a good idea and (b)
possible to be able to pass on to whichever server a parameter to add a
specific dir to its os.path. I was imagining that either the factory
param takes the form of
- str : as it is currently...
- (str, str) : a 2-tuple of str, where the frist str will be
interpreted as a dir to add to os.path

Then, the quixote.util.import_object(name) is similarly modified, e.g.
to:

quixote.util.import_object(name, add_to_path=None):
        if add_to_path is not None:
                if add_to_path not in os.path:
                        sys.path.insert(0, add_to_path)
        ...
        rest of function as as currently

Another way would be to add an "add_to_path" option to the various
server scripts, that will then be handled separately (and before) from
the import_object() call.

Does this sound reasonable, or is there a much simple way to do this?

mario

reply