[svn:mod_parrot] r477 - mod_parrot/trunk/languages/perl6/lib

[email protected] Wed, 29 Oct 2008 06:04:22 -0700 (PDT)
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Wed Oct 29 06:04:21 2008
New Revision: 477

Modified:
   mod_parrot/trunk/languages/perl6/lib/mod_perl6.pm

Log:
revert accidental commit from r476


Modified: mod_parrot/trunk/languages/perl6/lib/mod_perl6.pm
==============================================================================
--- mod_parrot/trunk/languages/perl6/lib/mod_perl6.pm	(original)
+++ mod_parrot/trunk/languages/perl6/lib/mod_perl6.pm	Wed Oct 29 06:04:21 2008
@@ -20,6 +20,8 @@
 use ModParrot::Const;
 use Apache::Const;
 
+our @preloaded_modules = ();
+our @postconfig_requires = ();
 our %loaded_modules;
 
 sub load($handler)
@@ -33,9 +35,6 @@
 sub server_create()
 {
     my %cfg;
-    %cfg<preloaded_modules> = [];
-    %cfg<postconfig_requires> = [];
-    push(%cfg<preloaded_modules>, "My::Test");
     return %cfg;
 }
 
@@ -45,94 +44,61 @@
     return %cfg;
 }
 
-# determine the type of handler and call it appropriately
-# handler types are: package, subroutine, and method
-# XXX currently forces package handlers
-# XXX broken until we can pass flattened arrays to handler()
-#sub call_handler($handler, *@args)
-#{
-#    my $status = ::($handler)::handler(*@args);
-#}
-
 sub response_handler($ctx)
 {
     my $r = $ctx.request_rec();
 
     unless ($r.handler() ~~ any(<modperl6 perl6-script>)) {
-        return $Apache::Const::DECLINED;
+        return $Apache::Const::DECLINED
     }
 
     my %cfg = ModParrot::Apache::Module::get_config("modparrot_perl6_module");
     my %dircfg = ModParrot::Apache::Module::get_config("modparrot_perl6_module",
         $r.per_dir_config());
 
-    my $handler = %dircfg<response_handler>;
+    my $handler = %dircfg{'response_handler'};
     load($handler);
 
     $r.content_type('text/html');
-    # XXX switch to call_handler when flattened array passing is fixed
-    #my $status = call_handler($handler, $r);
     my $status = ::($handler)::handler($r);
     return $status;
 }
 
-sub post_config_handler($ctx)
+sub post_config_handler($ctx, $handler)
 {
     #my $conf_pool = $ctx.conf_pool();
     #my $log_pool = $ctx.log_pool();
     #my $temp_pool = $ctx.temp_pool();
     #my $s = $ctx.server_rec();
 
-    my %cfg = ModParrot::Apache::Module::get_config("modparrot_perl6_module");
-    $*ERR.say("modules: " ~ join(',', %cfg<preloaded_modules>));
-
     # preload modules
-    for %cfg<preloaded_modules> -> $m {
-        $*ERR.say("loading $m");
-        use $m;
+    for @preloaded_modules -> $m {
+        # XXX fix when namespace interpolation works
+        # use ::($m);
+        eval "use $m";
     }
 
     # load postconfig requires
-    for %cfg<postconfig_requires> -> $r {
+    for @postconfig_requires -> $r {
+        # XXX does this work???
         require $r;
     }
 
-    my $handler = %cfg<post_config_handler>;
-    unless ($handler) {
-        return $Apache::Const::OK;
-    }
-
     # run the postconfig handler
     load($handler);
-    # XXX switch to call_handler when flattened array passing is fixed
-    # XXX fix when we have pool & server_rec objects
-    #my $status = call_handler($handler, $conf_pool, $log_pool, $temp_pool, $s);
-    #my $status = call_handler($handler);
+    #my $status = ::($handler)::handler($conf_pool, $log_pool, $temp_pool, $s);
     my $status = ::($handler)::handler();
     return $status;
 }
 
 sub cmd_perl6responsehandler(%dircfg, @args)
 {
-    %dircfg<response_handler> = @args[0];
-}
-
-sub cmd_perl6module(%mconfig, @args)
-{
-    my %cfg = ModParrot::Apache::Module::get_config("modparrot_perl6_module");
-    push(%cfg<preloaded_modules>, @args[0]);
+    %dircfg{'response_handler'} = @args[0];
 }
 
 # register configuration directives
 my @cmds = (
     {
-        'name' => 'Perl6Module',
-        'args_how' => $Apache::Const::TAKE1,
-        'func' => &cmd_perl6module,
-        'req_override' => $Apache::Const::RSRC_CONF,
-        'errmsg' => 'usage: Perl6Module module'
-    },
-    {
         'name' => 'Perl6ResponseHandler',
         'args_how' => $Apache::Const::TAKE1,
         'func' => &cmd_perl6responsehandler,
@@ -143,7 +109,6 @@
 
 # register hooks
 my @hooks = (
-    $ModParrot::Const::MP_HOOK_POST_CONFIG,
     $ModParrot::Const::MP_HOOK_RESPONSE
 );