[interchange-cvs] interchange - heins modified 2 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Tue Dec 13 09:39:08 EST 2005
User: heins
Date: 2005-12-13 14:39:08 GMT
Modified: lib/Vend Config.pm Dispatch.pm
Log:
* Change AutoEnd to use same methodology as Autoload for cleanup routines.
* Add ability to add Cleanup_code just like we add Dispatch_code now, allows
extensions to do things at end of a page session.
* Safe enough to commit to stable at next point release (or sooner if people
want to unbend).
Revision Changes Path
2.191 +28 -4 interchange/lib/Vend/Config.pm
rev 2.191, prev_rev 2.190
Index: Config.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.190
retrieving revision 2.191
diff -u -r2.190 -r2.191
--- Config.pm 29 Nov 2005 02:19:07 -0000 2.190
+++ Config.pm 13 Dec 2005 14:39:08 -0000 2.191
@@ -1,6 +1,6 @@
# Vend::Config - Configure Interchange
#
-# $Id: Config.pm,v 2.190 2005/11/29 02:19:07 mheins Exp $
+# $Id: Config.pm,v 2.191 2005/12/13 14:39:08 mheins Exp $
#
# Copyright (C) 2002-2005 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -39,7 +39,9 @@
@Locale_directives_ary @Locale_directives_scalar
@Locale_directives_code %tagCanon
%ContainerSave %ContainerTrigger %ContainerSpecial %ContainerType
- %Default %Dispatch_code %Dispatch_priority
+ %Default
+ %Dispatch_code %Dispatch_priority
+ %Cleanup_code %Cleanup_priority
@Locale_directives_currency @Locale_keys_currency
$GlobalRead $SystemCodeDone $SystemGroupsDone $CodeDest
$SystemReposDone $ReposDest @include
@@ -52,7 +54,7 @@
use Vend::Data;
use Vend::Cron;
-$VERSION = substr(q$Revision: 2.190 $, 10);
+$VERSION = substr(q$Revision: 2.191 $, 10);
my %CDname;
my %CPname;
@@ -3097,12 +3099,24 @@
);
my @Dispatches;
+my @Cleanups;
+
+%Cleanup_priority = (
+ AutoEnd => 1,
+);
%Dispatch_priority = (
CookieLogin => 1,
Locale => 2,
DiscountSpaces => 5,
- Autoload => 9,
+ Autoload => 8,
+);
+
+%Cleanup_code = (
+ AutoEnd => sub {
+#::logDebug("Doing AutoEnd dispatch...");
+ Vend::Dispatch::run_macro($Vend::Cfg->{AutoEnd});
+ },
);
%Dispatch_code = (
@@ -3448,6 +3462,11 @@
push @Dispatches, 'Autoload';
return 1;
},
+ AutoEnd => sub {
+ return 1 unless $C->{AutoEnd};
+ push @Cleanups, 'AutoEnd';
+ return 1;
+ },
External => sub {
return 1 unless $C->{External};
unless($Global::External) {
@@ -3485,6 +3504,7 @@
sub set_defaults {
@Dispatches = ();
+ @Cleanups = ();
for(keys %Default) {
my ($status, $error) = $Default{$_}->($C->{$_});
next if $status;
@@ -3497,8 +3517,12 @@
);
}
@Dispatches = sort { $Dispatch_priority{$a} cmp $Dispatch_priority{$b} } @Dispatches;
+ @Cleanups = sort { $Cleanup_priority{$a} cmp $Cleanup_priority{$b} } @Cleanups;
for(@Dispatches) {
push @{ $C->{DispatchRoutines} ||= [] }, $Dispatch_code{$_};
+ }
+ for(@Cleanups) {
+ push @{ $C->{CleanupRoutines} ||= [] }, $Cleanup_code{$_};
}
$Have_set_global_defaults = 1;
return;
1.61 +6 -5 interchange/lib/Vend/Dispatch.pm
rev 1.61, prev_rev 1.60
Index: Dispatch.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Dispatch.pm,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- Dispatch.pm 31 Oct 2005 15:13:09 -0000 1.60
+++ Dispatch.pm 13 Dec 2005 14:39:08 -0000 1.61
@@ -1,6 +1,6 @@
# Vend::Dispatch - Handle Interchange page requests
#
-# $Id: Dispatch.pm,v 1.60 2005/10/31 15:13:09 mheins Exp $
+# $Id: Dispatch.pm,v 1.61 2005/12/13 14:39:08 mheins Exp $
#
# Copyright (C) 2002-2005 Interchange Development Group
# Copyright (C) 2002 Mike Heins <mike at perusion.net>
@@ -26,7 +26,7 @@
package Vend::Dispatch;
use vars qw($VERSION);
-$VERSION = substr(q$Revision: 1.60 $, 10);
+$VERSION = substr(q$Revision: 1.61 $, 10);
use POSIX qw(strftime);
use Vend::Util;
@@ -1639,9 +1639,10 @@
do_page() if $status;
#show_times("end page display") if $Global::ShowTimes;
- if(my $macro = $Vend::Cfg->{AutoEnd}) {
- run_macro($macro);
-#show_times("end AutoEnd macro") if $Global::ShowTimes;
+ if(my $ary = $Vend::Cfg->{CleanupRoutines}) {
+ for(@$ary) {
+ $_->();
+ }
}
}
More information about the interchange-cvs
mailing list