You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Nigel Hamilton <ni...@e1mail.com> on 2000/11/14 12:34:08 UTC

Virtual Hosts, Name Space Clashing and Apache::Registry

Hi,

	I'm encountering name space clashes with two virtual hosts on my
server while using Apache::Registry.

	Both sites use a settings module that returns a hash of
configuration parameters (e.g., fgcolour => blue, bgcolour => white).

	The settings module is called: settings.pm. 

	There are two versions of this module stored in different
directories (i.e., /site1/cgi-bin/settings.pm + /site2/cgi-bin/settings.pm
).

	The problem is, periodically the sites swap look and feel. 

	Intermittently, a site suddenly appears cross-dressed in the
other's colours etc!

	I'm using Apache::Registry as the handler. My understanding was
that Apache::Registry creates a unique name space for each subroutine it
loads (e.g., Apache::ROOT::cgi2bin::settings etc.).

	I could just rename the module .... but I'd like to know why
things are going awry.

	Are global variables not included in this unique name space?

	I'm using lexically scoped (my) variables to store the settings.

	For example: 

	use settings;	
	my %settings = settings::getSettings();	

	Any help would be much appreciated.	
	
NIge



Re: Virtual Hosts, Name Space Clashing and Apache::Registry

Posted by Gunther Birznieks <gu...@extropia.com>.
Nigel,

If you are referring to the loading of a look-and-feel module, you're out 
of luck. The module names themselves are global and do not take on the 
properties of the script namespace.

This is actually a *feature* so that different scripts can share the same 
modules. :)

I actually spent a lot of time wringing my hands on this problem because I 
want the look and feel of our apps to be .pm files. This issue is different 
from templating because even templates need some logic behind them which 
the view files generate.

So In the end, I came up with a "view loader" mechanism where each view is 
granted its own namespace using a special .pm loader that changes the 
package namespace that the view has.

Each view has two methods: new and display. new() creates the view and 
makes it sticky within the scripts namespace while display() actually 
generates the view's display routine.

You can read the view chapter at http://www.extropia.com/ExtropiaObjects/ 
if you want to know more about one workaround.

Later,
    Gunther

At 12:59 PM 11/14/00 +0100, Stas Bekman wrote:
>On Tue, 14 Nov 2000, Nigel Hamilton wrote:
>
> > Hi,
> >
> >       I'm encountering name space clashes with two virtual hosts on my
> > server while using Apache::Registry.
>
>http://thingy.kcilink.com/modperlguide/config/A_Script_From_One_Virtual_Host_C.html
>
>
>_____________________________________________________________________
>Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
>http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
>mailto:stas@stason.org   http://apachetoday.com http://jazzvalley.com
>http://singlesheaven.com http://perlmonth.com   perl.org   apache.org

__________________________________________________
Gunther Birznieks (gunther.birznieks@extropia.com)
eXtropia - The Web Technology Company
http://www.extropia.com/


Re: Virtual Hosts, Name Space Clashing and Apache::Registry

Posted by Stas Bekman <st...@stason.org>.
On Tue, 14 Nov 2000, Nigel Hamilton wrote:

> Hi,
> 
> 	I'm encountering name space clashes with two virtual hosts on my
> server while using Apache::Registry.

http://thingy.kcilink.com/modperlguide/config/A_Script_From_One_Virtual_Host_C.html


_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide 
mailto:stas@stason.org   http://apachetoday.com http://jazzvalley.com
http://singlesheaven.com http://perlmonth.com   perl.org   apache.org