Re: Having configuration-data in a package with multiple instances of the same app

"[email protected]" <[email protected]> Thu, 19 Dec 2019 08:38:30 +0100
Newsgroups gmane.comp.web.mason.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============3541795917259542739==
Content-Type: multipart/alternative;
 boundary="------------10BB43204248477EDE51EA61"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------10BB43204248477EDE51EA61
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit

Hello!

Thanks for support.

Here is the essential of my sample for app1 and app2. I try to put a 
config-item (the color) into a package. The color should be different 
between app1 and app2.
The config-package has in every app the same name MyConfig (that may be 
the problem). I can resolve the problem if I make MyConfig1 for app1 and 
MyConfig2 for app2.
But lets think I have not 2 apps but 10. I would need to change every 
apperance of MyConfig::getColor in the code.

Cheers
Chris


--app1/autohandler--
% $m->call_next ();
<%init>
use strict;
use warnings;
use lib "/var/www/html/app1";
use MyConfig;
</%init>


--/app1/MyConfig.pm--
package MyConfig;
sub getColor
{
      return "red";
}
1;


--app2/index.mas--
<% MyConfig::getColor () %>


--app2/autohandler--
% $m->call_next ();
<%init>
use strict;
use warnings;
use lib "/var/www/html/app2";
use MyConfig;
</%init>


--/app12MyConfig.pm--
package MyConfig;
sub getColor
{
      return "blue";
}
1;

--app2/index.mas--
<% MyConfig::getColor () %>





On 19.12.19 02:41, Han Do Jin wrote:
> Can you show us your autohandler? I think maybe you should be using 
> <%attr> to affect a shared template rather than put configs into a 
> shared library. I'm guessing when you say you want same application 
> 2nd time on same server that they are both running in the same apache 
> instance? I run multiple sites (virtualhosts) on the same apache 
> instance and use a few techniques for altering the core/shared master 
> template as well as which database to connect to. Let's see what you 
> are trying to accomplish and I can try and offer you some more 
> concrete examples.
>
> Chris
>
>
> On Wed, Dec 18, 2019 at 5:16 PM [email protected] 
> <mailto:[email protected]> <[email protected] 
> <mailto:[email protected]>> wrote:
>
>     Hello!
>
>     I am new to Mason and have a little problem in having the same
>     application (but with different configuration) multiple times on a
>     server in different paths.
>     Think the problem is because of the global scope of packages.
>
>     I have the configuation data in a package - lets say MyConfig.
>
>     e.g.
>     package MyConfig;
>
>     sub getColor
>     {
>          return "red";
>     }
>
>     1;
>
>     I load it in the autohandler and via MyConfig::getColor () it is
>     available in all parts of the application.
>
>     Lets say I wanna have the same application a 2nd time on the same
>     server
>     but with a different color.
>     So both applications would have the same files but MyConfig.pm
>     differs.
>
>     That does not work. The color get mixed up unless I do not have
>     unique
>     names for the config-package (e.g. MyConfig1 in the 1st
>     application and
>     MyConfig2 in the 2nd) again.
>     Thats not great because I also need to change every appearence of
>     MyConfig::getColor () to the new name.
>
>     Is there a way I can bring such static configuration data in the
>     application in a more elegant way?
>
>     Thanks for help!
>     Chris
>
>
>     _______________________________________________
>     Mason-users mailing list
>     [email protected]
>     <mailto:[email protected]>
>     https://lists.sourceforge.net/lists/listinfo/mason-users
>


--------------10BB43204248477EDE51EA61
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Hello!<br>
    <br>
    Thanks for support. <br>
    <br>
    Here is the essential of my sample for app1 and app2. I try to put a
    config-item (the color) into a package. The color should be
    different between app1 and app2.<br>
    The config-package has in every app the same name MyConfig (that may
    be the problem). I can resolve the problem if I make MyConfig1 for
    app1 and MyConfig2 for app2.<br>
    But lets think I have not 2 apps but 10. I would need to change
    every apperance of MyConfig::getColor in the code.<br>
    <br>
    Cheers<br>
    Chris<br>
    <br>
    <br>
    --app1/autohandler--<br>
    % $m-&gt;call_next ();<br>
    &lt;%init&gt;<br>
    use strict;<br>
    use warnings;<br>
    use lib "/var/www/html/app1";<br>
    use MyConfig;<br>
    &lt;/%init&gt;<br>
    <br>
    <br>
    --/app1/MyConfig.pm--<br>
    package MyConfig;<br>
    sub getColor<br>
    {<br>
         return "red";<br>
    }<br>
    1;<br>
    <br>
    <br>
    --app2/index.mas--<br>
    &lt;% MyConfig::getColor () %&gt;<br>
    <br>
    <br>
    --app2/autohandler--<br>
    % $m-&gt;call_next ();<br>
    &lt;%init&gt;<br>
    use strict;<br>
    use warnings;<br>
    use lib "/var/www/html/app2";<br>
    use MyConfig;<br>
    &lt;/%init&gt;<br>
    <br>
    <br>
    --/app12MyConfig.pm--<br>
    package MyConfig;<br>
    sub getColor<br>
    {<br>
         return "blue";<br>
    }<br>
    1;<br>
    <br>
    --app2/index.mas--<br>
    &lt;% MyConfig::getColor () %&gt;<br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 19.12.19 02:41, Han Do Jin wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CADBG4qW4jfJ7prTXRd1e4gkGyFZnVd_BLc7G5zpkHfDowKh5sQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Can you show us your autohandler? I think maybe you should
          be using &lt;%attr&gt; to affect a shared template rather than
          put configs into a shared library. I'm guessing when you say
          you want same application 2nd time on same server that they
          are both running in the same apache instance? I run multiple
          sites (virtualhosts) on the same apache instance and use a few
          techniques for altering the core/shared master template as
          well as which database to connect to. Let's see what you are
          trying to accomplish and I can try and offer you some more
          concrete examples.</div>
        <div><br>
        </div>
        <div>Chris</div>
        <div><br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Wed, Dec 18, 2019 at 5:16
          PM <a href="mailto:[email protected]" moz-do-not-send="true">[email protected]</a>
          &lt;<a href="mailto:[email protected]" moz-do-not-send="true">[email protected]</a>&gt;
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello!<br>
          <br>
          I am new to Mason and have a little problem in having the same
          <br>
          application (but with different configuration) multiple times
          on a <br>
          server in different paths.<br>
          Think the problem is because of the global scope of packages.<br>
          <br>
          I have the configuation data in a package - lets say MyConfig.<br>
          <br>
          e.g.<br>
          package MyConfig;<br>
          <br>
          sub getColor<br>
          {<br>
               return "red";<br>
          }<br>
          <br>
          1;<br>
          <br>
          I load it in the autohandler and via MyConfig::getColor () it
          is <br>
          available in all parts of the application.<br>
          <br>
          Lets say I wanna have the same application a 2nd time on the
          same server <br>
          but with a different color.<br>
          So both applications would have the same files but MyConfig.pm
          differs.<br>
          <br>
          That does not work. The color get mixed up unless I do not
          have unique <br>
          names for the config-package (e.g. MyConfig1 in the 1st
          application and <br>
          MyConfig2 in the 2nd) again.<br>
          Thats not great because I also need to change every appearence
          of <br>
          MyConfig::getColor () to the new name.<br>
          <br>
          Is there a way I can bring such static configuration data in
          the <br>
          application in a more elegant way?<br>
          <br>
          Thanks for help!<br>
          Chris<br>
          <br>
          <br>
          _______________________________________________<br>
          Mason-users mailing list<br>
          <a href="mailto:[email protected]"
            target="_blank" moz-do-not-send="true">[email protected]</a><br>
          <a
            href="https://lists.sourceforge.net/lists/listinfo/mason-users"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.sourceforge.net/lists/listinfo/mason-users</a><br>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>

--------------10BB43204248477EDE51EA61--


--===============3541795917259542739==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============3541795917259542739==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

--===============3541795917259542739==--