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

Accessing session data outside of mod_perl env

Expand Messages
  • Fred Moyer
    Greetings, I m attempting to manipulate the $Application object from a cronjob and need some guidance. I have a cron script which generates an object from
    Message 1 of 2 , Jan 13, 2004
    • 0 Attachment
      Greetings,

      I'm attempting to manipulate the $Application object from a cronjob and
      need some guidance. I have a cron script which generates an object from
      data which I want to embed into the session. I could write a handler
      that gets called via LWP from the cron and does the required session
      manipulation but I'm wondering if there's a more elegant solution.
      Here's what I have so far in the cronjob:

      use Apache::ASP;
      use Apache::ASP::Application;
      my $object = My::App->new();
      my $asp = Apache::ASP->new($a_request_object);
      $asp::Application->{'object'} = { object => $object };

      So the question is what can I use for $a_request_object? I'm using mp2
      so Apache::FakeRequest is out - any ideas?

      Thanks,

      Fred


      ---------------------------------------------------------------------
      To unsubscribe, e-mail: asp-unsubscribe@...
      For additional commands, e-mail: asp-help@...
    • Josh Chamas
      ... If you want a fake Apache request object, try Apache::ASP::CGI To see how its used, you can check out the asp-perl script. Its not really documented, but
      Message 2 of 2 , Jan 17, 2004
      • 0 Attachment
        Fred Moyer wrote:
        > Greetings,
        >
        > I'm attempting to manipulate the $Application object from a cronjob and
        > need some guidance. I have a cron script which generates an object from
        > data which I want to embed into the session. I could write a handler
        > that gets called via LWP from the cron and does the required session
        > manipulation but I'm wondering if there's a more elegant solution.
        > Here's what I have so far in the cronjob:
        >
        > use Apache::ASP;
        > use Apache::ASP::Application;
        > my $object = My::App->new();
        > my $asp = Apache::ASP->new($a_request_object);
        > $asp::Application->{'object'} = { object => $object };
        >
        > So the question is what can I use for $a_request_object? I'm using mp2
        > so Apache::FakeRequest is out - any ideas?
        >

        If you want a fake Apache request object, try Apache::ASP::CGI

        To see how its used, you can check out the asp-perl script. Its not
        really documented, but the obvious methods are pretty stable, as everything
        from asp-perl to the t/*.t script depend on it.

        I would recommend doing an lwp-request to a real script though, as then
        you get to work with guaranteed APIs.

        What I would really recommend is having some extra data file your cron job
        writes to that can be initialize in Script_OnStart, and not stored in
        $Application at all. $Application usage for any really big data is probably
        pretty slow & performance intensive.

        If you are really brave, you can use MLDBM::Sync to access the files
        in StateDir directly. If you use MLDBM::Sync, this will be safe, if you
        use MLDBM, it won't be.

        Regards,

        Josh
        ________________________________________________________________
        Josh Chamas, Founder phone:925-552-0128
        Chamas Enterprises Inc. http://www.chamas.com
        NodeWorks Link Checker 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.