Loading ...
Sorry, an error occurred while loading the content.

RE: Regarding subs and global.asa

Expand Messages
  • Thom Crane
    Please forgive my hastiness to get this problem solved. I have used require global.asa to get my problem worked out, but this doesn t seem to be the proper
    Message 1 of 6 , Oct 5, 2002
    View Source
    • 0 Attachment
      Please forgive my hastiness to get this problem solved.
      I have used require "global.asa" to get my problem worked out, but this
      doesn't seem to be the proper way of handling this file from the reading I
      have done.
      Although not stated explicitly, it has been my feeling from reading at the
      site and on this list that global.asa has some higher purpose than just
      being another include file.

      Is using a require the proper way to handle this? If not, would some kind
      soul (who has nothing better to do this weekend), please help out a
      burgeoning Apache::ASP user with some basics?

      Thanks so much.

      Thom

      -----Original Message-----
      From: Thom Crane [mailto:mail@...]
      Sent: Saturday, October 05, 2002 11:10 AM
      To: asp@...
      Subject: Regarding subs and global.asa


      Hello all,
      I am sure this is quite the newbie question, but alas, a newbie I am :)

      I keep getting errors that say I am trying to use an undefined sub. The
      error (regardless of which sub it points out) is in the following form in
      the error log:

      <quote>

      [Sat Oct 5 08:34:24 2002] [error] [asp] [2246] [error] Undefined subroutine
      &Apache::ASP::Compiles::__ASP__tmpx9936a616c549519afe239b14a8568b6c::mysub
      called at index.asp line 210. <--> ,
      /usr/lib/perl5/site_perl/5.6.0/Apache/ASP.pm line 1413

      </quote>

      In this case, I am calling the sub in this manner in the program:

      &mysub()

      My global.asa is set up as follows:

      #global.asa

      sub mysub{

      ...lots o' code...
      }

      I have tried with all my might to find the answer to this conundrum on the
      web site and archives, but I am newbie enough not to be able to put together
      the clues...

      Any ideas, comments, tongue-lashings? <g>

      Thanks in advance,

      Thom Crane






      ---------------------------------------------------------------------
      To unsubscribe, e-mail: asp-unsubscribe@...
      For additional commands, e-mail: asp-help@...




      ---------------------------------------------------------------------
      To unsubscribe, e-mail: asp-unsubscribe@...
      For additional commands, e-mail: asp-help@...
    • dave_apache_asp
      Thom: I think global.asa is only supposed to contain event-triggered (*_On*) subroutines and maybe local subs called by the _On subs. The best place I ve
      Message 2 of 6 , Oct 5, 2002
      View Source
      • 0 Attachment
        Thom:

        I think global.asa is only supposed to contain event-triggered
        (*_On*) subroutines and maybe local subs called by the _On subs. The
        best place I've found for non-event-triggered subs is in separate
        modules. You can pre-load and pre-compile frequently used modules in
        Application_OnStart though and then refer to them from any page.
        Application_OnStart is only for GLOBAL stuff though, and I think
        changes require an Apache restart (in contrast to Script_OnStart,
        which is apparently re-compiled/executed every time). This also
        means changes to the modules being loaded will require an Apache
        restart since they are only loaded and compiled once. (I could be
        wrong as I'm not the expert; this is just the behavior I've observed.)

        For example, part of my global.asa might look like this.

        #global.asa
        sub Application_OnStart {

        use InputProcessor;
        use UserCheck;

        # read in global config params (e.g. db connect strings)
        open (CFG, '/outside/of/web/tree/app.cfg');
        while (<CFG>) {
        chomp;
        my ($key, $value) = split;
        $Application->{$key} = $value;
        }
        close CFG;
        }

        Then, for example, in login.asp I just say

        #login.asp
        ...(html)...
        <%
        my $userCheck = new UserCheck;
        if ($userCheck->checkUser($ASPObjects)) {
        $Response->Redirect(...)
        }
        else { #...etc.
        %>

        hope this helps! If not, at least I tried :)

        -dave
        --- In apache-asp@y..., "Thom Crane" <mail@t...> wrote:
        > Please forgive my hastiness to get this problem solved.
        > I have used require "global.asa" to get my problem worked
        out, but this
        > doesn't seem to be the proper way of handling this file from the
        reading I
        > have done.
        > Although not stated explicitly, it has been my feeling from
        reading at the
        > site and on this list that global.asa has some higher purpose than
        just
        > being another include file.
        >
        > Is using a require the proper way to handle this? If not, would
        some kind
        > soul (who has nothing better to do this weekend), please help out a
        > burgeoning Apache::ASP user with some basics?
        >
        > Thanks so much.
        >
        > Thom
        >
        > -----Original Message-----
        > From: Thom Crane [mailto:mail@t...]
        > Sent: Saturday, October 05, 2002 11:10 AM
        > To: asp@p...
        > Subject: Regarding subs and global.asa
        >
        >
        > Hello all,
        > I am sure this is quite the newbie question, but alas, a
        newbie I am :)
        >
        > I keep getting errors that say I am trying to use an
        undefined sub. The
        > error (regardless of which sub it points out) is in the following
        form in
        > the error log:
        >
        > <quote>
        >
        > [Sat Oct 5 08:34:24 2002] [error] [asp] [2246] [error] Undefined
        subroutine
        >
        &Apache::ASP::Compiles::__ASP__tmpx9936a616c549519afe239b14a8568b6c::m
        ysub
        > called at index.asp line 210. <--> ,
        > /usr/lib/perl5/site_perl/5.6.0/Apache/ASP.pm line 1413
        >
        > </quote>
        >
        > In this case, I am calling the sub in this manner in the program:
        >
        > &mysub()
        >
        > My global.asa is set up as follows:
        >
        > #global.asa
        >
        > sub mysub{
        >
        > ...lots o' code...
        > }
        >
        > I have tried with all my might to find the answer to this conundrum
        on the
        > web site and archives, but I am newbie enough not to be able to put
        together
        > the clues...
        >
        > Any ideas, comments, tongue-lashings? <g>
        >
        > Thanks in advance,
        >
        > Thom Crane
        >
        >
        >
        >
        >
        >
        > --------------------------------------------------------------------
        -
        > To unsubscribe, e-mail: asp-unsubscribe@p...
        > For additional commands, e-mail: asp-help@p...
        >
        >
        >
        >
        > --------------------------------------------------------------------
        -
        > To unsubscribe, e-mail: asp-unsubscribe@p...
        > For additional commands, e-mail: asp-help@p...


        ---------------------------------------------------------------------
        To unsubscribe, e-mail: asp-unsubscribe@...
        For additional commands, e-mail: asp-help@...
      • Josh Chamas
        ... As dave pointed out, this is where the ASP events definitions reside. However, since the global.asa is also compiled into the same perl package as the rest
        Message 3 of 6 , Oct 6, 2002
        View Source
        • 0 Attachment
          Thom Crane wrote:
          > Please forgive my hastiness to get this problem solved.
          > I have used require "global.asa" to get my problem worked out, but this
          > doesn't seem to be the proper way of handling this file from the reading I
          > have done.
          > Although not stated explicitly, it has been my feeling from reading at the
          > site and on this list that global.asa has some higher purpose than just
          > being another include file.

          As dave pointed out, this is where the ASP events definitions reside.
          However, since the global.asa is also compiled into the same perl
          package as the rest of the scripts & includes in your application,
          common subroutines & globals can be defined in there too for use
          in your application.

          The trick with getting global.asa to be compiled is your PerlSetVar Global
          setting needs to point to the location it resides at. If your
          global.asa resides in the same directory as your scripts, then set
          Global to . If you would like your $Session & $Application files
          not stored in ./.state in this case ( the default ), then you can
          set StateDir to some other directory ( like /tmp/my_asp_app )

          > Is using a require the proper way to handle this? If not, would some kind
          > soul (who has nothing better to do this weekend), please help out a
          > burgeoning Apache::ASP user with some basics?

          Doing a require on global.asa has a similar effect, but you should allow
          for Apache::ASP to reload your global.asa, which it will do correctly
          whenever you change it.

          Regards,

          Josh
          ________________________________________________________________
          Josh Chamas, Founder phone:925-552-0128
          Chamas Enterprises Inc. http://www.chamas.com
          NodeWorks Link Checking http://www.nodeworks.com


          ---------------------------------------------------------------------
          To unsubscribe, e-mail: asp-unsubscribe@...
          For additional commands, e-mail: asp-help@...
        • Thom Crane
          Where is PerlSetVar defined? I don t have access to the server, therefore I can make no changes to httpd.conf. Can I define it in .htaccess? Thom ... From:
          Message 4 of 6 , Oct 6, 2002
          View Source
          • 0 Attachment
            Where is PerlSetVar defined? I don't have access to the server, therefore I
            can make no changes to httpd.conf. Can I define it in .htaccess?

            Thom

            -----Original Message-----
            From: Josh Chamas [mailto:josh@...]
            Sent: Sunday, October 06, 2002 1:42 PM
            To: Thom Crane
            Cc: asp@...
            Subject: Re: Regarding subs and global.asa


            Thom Crane wrote:
            > Please forgive my hastiness to get this problem solved.
            > I have used require "global.asa" to get my problem worked out, but this
            > doesn't seem to be the proper way of handling this file from the reading I
            > have done.
            > Although not stated explicitly, it has been my feeling from reading at
            the
            > site and on this list that global.asa has some higher purpose than just
            > being another include file.

            As dave pointed out, this is where the ASP events definitions reside.
            However, since the global.asa is also compiled into the same perl
            package as the rest of the scripts & includes in your application,
            common subroutines & globals can be defined in there too for use
            in your application.

            The trick with getting global.asa to be compiled is your PerlSetVar Global
            setting needs to point to the location it resides at. If your
            global.asa resides in the same directory as your scripts, then set
            Global to . If you would like your $Session & $Application files
            not stored in ./.state in this case ( the default ), then you can
            set StateDir to some other directory ( like /tmp/my_asp_app )

            > Is using a require the proper way to handle this? If not, would some kind
            > soul (who has nothing better to do this weekend), please help out a
            > burgeoning Apache::ASP user with some basics?

            Doing a require on global.asa has a similar effect, but you should allow
            for Apache::ASP to reload your global.asa, which it will do correctly
            whenever you change it.

            Regards,

            Josh
            ________________________________________________________________
            Josh Chamas, Founder phone:925-552-0128
            Chamas Enterprises Inc. http://www.chamas.com
            NodeWorks Link Checking http://www.nodeworks.com




            ---------------------------------------------------------------------
            To unsubscribe, e-mail: asp-unsubscribe@...
            For additional commands, e-mail: asp-help@...
          • Josh Chamas
            ... At least on my server, I can add PerlSetVar configs to .htaccess. --Josh ________________________________________________________________ Josh Chamas,
            Message 5 of 6 , Oct 6, 2002
            View Source
            • 0 Attachment
              Thom Crane wrote:
              > Where is PerlSetVar defined? I don't have access to the server, therefore I
              > can make no changes to httpd.conf. Can I define it in .htaccess?
              >

              At least on my server, I can add PerlSetVar configs to .htaccess.

              --Josh
              ________________________________________________________________
              Josh Chamas, Founder phone:925-552-0128
              Chamas Enterprises Inc. http://www.chamas.com
              NodeWorks Link Checking http://www.nodeworks.com


              ---------------------------------------------------------------------
              To unsubscribe, e-mail: asp-unsubscribe@...
              For additional commands, e-mail: asp-help@...
            Your message has been successfully submitted and would be delivered to recipients shortly.