diff options
author | wurblzap%gmail.com <> | 2006-08-20 00:20:23 +0000 |
---|---|---|
committer | wurblzap%gmail.com <> | 2006-08-20 00:20:23 +0000 |
commit | 0ee4621e7828a205189368aa9b8a515574d9c030 (patch) | |
tree | 93caacf40fc87a27e224e8fefa6b7284e686e918 /Bugzilla.pm | |
parent | Bug 349198: 001compile.t must not compile mod_perl.pl - Patch by Frédéric B... (diff) | |
download | bugzilla-0ee4621e7828a205189368aa9b8a515574d9c030.tar.gz bugzilla-0ee4621e7828a205189368aa9b8a515574d9c030.tar.bz2 bugzilla-0ee4621e7828a205189368aa9b8a515574d9c030.zip |
Bug 224577: Bugzilla could use a web services interface.
Patch by Marc Schumann <wurblzap@gmail.com>;
r=mkanat; a=myk
Diffstat (limited to 'Bugzilla.pm')
-rw-r--r-- | Bugzilla.pm | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm index 21a741e59..19c52ee2f 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -20,6 +20,7 @@ # Contributor(s): Bradley Baetz <bbaetz@student.usyd.edu.au> # Erik Stambaugh <erik@dasbistro.com> # A. Karl Kornel <karl@kornel.name> +# Marc Schumann <wurblzap@gmail.com> package Bugzilla; @@ -263,13 +264,37 @@ sub dbh { return request_cache()->{dbh}; } -sub batch { +sub error_mode { my $class = shift; my $newval = shift; if (defined $newval) { - request_cache()->{batch} = $newval; + request_cache()->{error_mode} = $newval; } - return request_cache()->{batch} || 0; + return request_cache()->{error_mode} + || Bugzilla::Constants::ERROR_MODE_WEBPAGE; +} + +sub usage_mode { + my $class = shift; + my $newval = shift; + if (defined $newval) { + if ($newval == USAGE_MODE_BROWSER) { + $class->error_mode(ERROR_MODE_WEBPAGE); + } + elsif ($newval == USAGE_MODE_CMDLINE) { + $class->error_mode(ERROR_MODE_DIE); + } + elsif ($newval == USAGE_MODE_WEBSERVICE) { + $class->error_mode(ERROR_MODE_DIE_SOAP_FAULT); + } + else { + ThrowCodeError('usage_mode_invalid', + {'invalid_usage_mode', $newval}); + } + request_cache()->{usage_mode} = $newval; + } + return request_cache()->{usage_mode} + || Bugzilla::Constants::USAGE_MODE_BROWSER; } sub switch_to_shadow_db { @@ -477,12 +502,35 @@ Essentially, causes calls to C<Bugzilla-E<gt>user> to return C<undef>. This has effect of logging out a user for the current request only; cookies and database sessions are left intact. -=item C<batch> +=item C<error_mode> + +Call either C<Bugzilla->error_mode(Bugzilla::Constants::ERROR_MODE_DIE)> +or C<Bugzilla->error_mode(Bugzilla::Constants::ERROR_MODE_DIE_SOAP_FAULT)> to +change this flag's default of C<Bugzilla::Constants::ERROR_MODE_WEBPAGE> and to +indicate that errors should be passed to error mode specific error handlers +rather than being sent to a browser and finished with an exit(). + +This is useful, for example, to keep C<eval> blocks from producing wild HTML +on errors, making it easier for you to catch them. +(Remember to reset the error mode to its previous value afterwards, though.) + +C<Bugzilla->error_mode> will return the current state of this flag. + +Note that C<Bugzilla->error_mode> is being called by C<Bugzilla->usage_mode> on +usage mode changes. + +=item C<usage_mode> + +Call either C<Bugzilla->usage_mode(Bugzilla::Constants::USAGE_MODE_CMDLINE)> +or C<Bugzilla->usage_mode(Bugzilla::Constants::USAGE_MODE_WEBSERVICE)> near the +beginning of your script to change this flag's default of +C<Bugzilla::Constants::USAGE_MODE_BROWSER> and to indicate that Bugzilla is +being called in a non-interactive manner. +This influences error handling because on usage mode changes, C<usage_mode> +calls C<Bugzilla->error_mode> to set an error mode which makes sense for the +usage mode. -Set to true, by calling Bugzilla->batch(1), to indicate that Bugzilla is -being called in a non-interactive manner and errors should be passed to -die() rather than being sent to a browser and finished with an exit(). -Bugzilla->batch will return the current state of this flag. +C<Bugzilla->usage_mode> will return the current state of this flag. =item C<dbh> |