1
# See bottom of file for license and copyright information
5
---+!! package Foswiki::Engine::Legacy
7
This engine supports legacy bin scripts that don't use
8
$Foswiki::cfg{SwitchBoard} yet.
10
It redefines Foswiki::Request::new and Foswiki::Response::new, so request and
11
response objects are singletons, making it possible to the engine finalization
12
phase invoked from the END block happens.
16
package Foswiki::Engine::Legacy;
20
my ( $request, $response );
23
if ( $ENV{GATEWAY_INTERFACE} ) {
24
require Foswiki::Engine::CGI;
25
@ISA = qw(Foswiki::Engine::CGI);
28
require Foswiki::Engine::CLI;
29
@ISA = qw(Foswiki::Engine::CLI);
31
no warnings 'redefine';
32
require Foswiki::Request;
33
my $req_new = \&Foswiki::Request::new;
34
*Foswiki::Request::new = sub {
35
if ( defined $request ) {
39
return $request = $req_new->(@_);
42
require Foswiki::Response;
43
my $res_new = \&Foswiki::Response::new;
44
*Foswiki::Response::new = sub {
45
if ( defined $response ) {
49
return $response = $res_new->(@_);
52
require Foswiki::EngineException;
57
$this = $this->SUPER::new(@_);
63
$Foswiki::engine->finalize( $response, $request )
64
if ref($response) && $response->isa('Foswiki::Response');
65
( $request, $response ) = ();
70
# Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/
72
# Copyright (C) 2008-2009 Foswiki Contributors. Foswiki Contributors
73
# are listed in the AUTHORS file in the root of this distribution.
74
# NOTE: Please extend that file, not this notice.
76
# Additional copyrights apply to some or all of the code in this
79
# Copyright (C) 1999-2007 Peter Thoeny, peter@thoeny.org
80
# and TWiki Contributors. All Rights Reserved. TWiki Contributors
81
# are listed in the AUTHORS file in the root of this distribution.
83
# This module is based/inspired on Catalyst framework. Refer to
85
# http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7010/lib/Catalyst.pm
87
# for credits and liscence details.
89
# This program is free software; you can redistribute it and/or
90
# modify it under the terms of the GNU General Public License
91
# as published by the Free Software Foundation; either version 2
92
# of the License, or (at your option) any later version. For
93
# more details read LICENSE in the root of this distribution.
95
# This program is distributed in the hope that it will be useful,
96
# but WITHOUT ANY WARRANTY; without even the implied warranty of
97
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
99
# As per the GPL, removal of this notice is prohibited.