You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Justin Luster <ju...@sawtoothsoftware.com> on 2003/03/18 23:55:26 UTC

required files not in a namespace?

Are "required" files in a namespace under Apache::Registry in Mod_Perl?
I have just done a simple test that seems to show that they are not in a
namespace.  In the documentation
(http://perl.apache.org/docs/1.0/guide/intro.html#Apache__Registry) it
says that the initial script is stored under a unique key to "prevent
script name collisions".  This seems to work for the main script that
you call but not for the "required" files that that script uses.

 

Here is my example:

 

Test1 Directory

            test1.pl

            libone.pl

 

Test2 Directory

            test1.pl

            libone.pl

 

test1.pl contains:           

 

print "Content-type: text/html\n\n";

            print "<html>";

            print "<head>";

            print "<title>Debug Test #1</title>";

            print "</head>";

            print "<body>";

 

            require "libone.pl";

 

            libone::A();

 

            print "<h1>Debug Test #1 Successful</h1>";

            print "</body>\n</html>\n";

 

libone.pl contains:

 

            #!/usr/bin/perl

 

package libone;

 

sub A

{

            print "Hello from A";

}

 

return 1;

 

In the 2nd copy of libone.pl, contained under the Test2 directory I
changed the output slightly to say "Hello from A - 2nd version".

 

I then restart Apache and try test1.pl from the Test1 directory and I
see "Hello from A".  I then try the test1.pl from the Test2 directory
and I still get "Hello from A".  If I restart Apache and try test1.pl
from the Test2 directory first I see "Hello from A - 2nd version".  If I
then try test1.pl from the Test1 directory I still get "Hello from A -
2nd version".

 

So it appears as though Apache::Registry is caching the first instance
of libone.pl and is not namespacing it as it does with the initial
script test1.pl.

 

If this is the case what can I do to fix it?  I view it as a big problem
because if my script is deployed I do not know if my script is going to
use my libone.pl or a libone.pl written by someone else that has already
been stored in the cache.  

 

I hope you understand my problem.  Please help.

 

Thanks.

 

My installation information is below.

 

MOD_PERL => mod_perl/1.26

SERVER_SOFTWARE => Apache/1.3.27 (Unix) (Red-Hat/Linux) mod_python/2.7.6
Python/1.5.2 mod_ssl/2.8.12 OpenSSL/0.9.6b DAV/1.0.2 PHP/4.1.2
mod_perl/1.26 mod_throttle/3.1.2

PERL_SEND_HEADER => On


Re: required files not in a namespace?

Posted by Stas Bekman <st...@stason.org>.
Justin Luster wrote:
> Are “required” files in a namespace under Apache::Registry in Mod_Perl?  
> I have just done a simple test that seems to show that they are not in a 
> namespace.  In the documentation 
> (http://perl.apache.org/docs/1.0/guide/intro.html#Apache__Registry) it 
> says that the initial script is stored under a unique key to “prevent 
> script name collisions”.  This seems to work for the main script that 
> you call but not for the “required” files that that script uses.

See:
http://perl.apache.org/docs/1.0/guide/porting.html#Name_collisions_with_Modules_and_libs


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com