httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Sergeant <m...@sergeant.org>
Subject Making Apache::Request a singleton
Date Tue, 12 Dec 2000 17:01:29 GMT
Can we make Apache::Request a singleton? Currently if you try to create
one after it has been initialised once it fails to see anything in the
POST data (because its already been read).

This patch should fix that, though I've not actually tested it yet:

--- Request.pm.old	Tue Dec 12 16:53:38 2000
+++ Request.pm	Tue Dec 12 16:59:31 2000
@@ -11,6 +11,15 @@
     __PACKAGE__->mod_perl::boot($VERSION);
 }

+sub new {
+    my ($class, $r, @extras) = @_;
+    if ($Apache::Request::_instance) {
+        return $Apache::Request::_instance;
+    }
+    $r->register_cleanup( sub { undef $Apache::Request::_instance; } );
+    return $Apache::Request::_instance = $class->new_instance($r,
@extras);
+}
+
 #just prototype methods here, moving to xs later
 sub param {
     my $self = shift;

--- Request.xs.old	Tue Dec 12 16:52:52 2000
+++ Request.xs	Tue Dec 12 16:53:31 2000
@@ -105,7 +105,7 @@
     av_push(perl_get_av("Apache::Request::ISA",TRUE),
newSVpv("Apache",6));

 Apache::Request
-ApacheRequest_new(class, r, ...)
+ApacheRequest_new_instance(class, r, ...)
     SV *class
     Apache r



-- 
<Matt/>

    /||    ** Director and CTO **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // **     Personal Web Site: http://sergeant.org/     **
     \\//
     //\\
    //  \\


Mime
View raw message