edan has asked for the wisdom of the Perl Monks concerning the following question:
We are trying to migrate an existing CGI codebase to mod_perl (Apache::Registry) for performance reasons. The problem we are having is with name-spaces, because the product is composed of a 'global' instance, and possibly many 'local' instances. Currently it works like this:
When a local instance is created, a new tree is created which is a copy of the global instance, and all of the CGIs and modules are symbolically linked to the global instance. This way, the global instance can be updated, and the local instance will get the changes, unless the local instance has modifications. A local instance is modified by breaking the symbolic link, i.e. copying the file to the local instance. This way local modifications can be made, with the tradeoff that global updates won't be seen. The CGIs use the local modules by modifying @INC to look in the local 'lib' diretory first.
Thus, all the CGIs and modules in all the instances use a module, which will be found in the local instance's include directory, but the module itself may or may not be a link to the global instance.
The example CGI would look like this:
#!perl BEGIN { unshift @INC, "$ENV{LOCAL_INSTANCE}/lib"; } use Some::Module; # ...
When we try to run this under mod_perl, the system breaks down. The first time a particular apache child gets called, it's compiled, and uses the module appropriate for the instance. But the next time it gets called, for possibly some other instance, it's still using the module that was compiled the first time. We need to the CGI to uise the module that is appropriate for the instance that it was caled for.
and changing the CGIs to use LOCAL_INSTANCE::Some::Module; as well as any statements that would have been something like my $obj = Some::Module->new etc. Also doesn't seem like the right way to do it, and requires major structural changes.package LOCAL_INSTANCE::Some::Module;
Has anyone run into this sort of problem before, and come up with a workable solution?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Name-Space problems migrating to Apache::Registry
by Corion (Patriarch) on Mar 10, 2004 at 10:42 UTC | |
|
Re: Name-Space problems migrating to Apache::Registry
by sheep (Chaplain) on Mar 10, 2004 at 11:32 UTC | |
|
Re: Name-Space problems migrating to Apache::Registry
by perrin (Chancellor) on Mar 10, 2004 at 15:38 UTC | |
by edan (Curate) on Mar 10, 2004 at 15:44 UTC | |
|
Re: Name-Space problems migrating to Apache::Registry
by bageler (Hermit) on Mar 10, 2004 at 13:12 UTC | |
by edan (Curate) on Mar 10, 2004 at 13:52 UTC |