RSS

trunk : 5305

mkanat%bugzilla.org
2007-10-19 07:58:48
Revision ID: cvs-1:mkanatbugzilla.org-20071019125848-uxj9c3tfmoj2zpk0
Bug 396243: Allow extensions (aka plugins) to extend the WebService interface This also includes the first checkin of the example plugin. Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=ghendricks, a=mkanat

collapse all collapse all

added added

removed removed

4
localconfig
4
localconfig
5
index.html
5
index.html
6
old-params.txt
6
old-params.txt
7
extensions
 
 
62
 
62
 
63
=head1 NAME
63
=head1 NAME
64
 
64
 
65
Bugzilla::Hook - Extendible extension hooks for Bugzilla code
65
Bugzilla::Hook - Extendable extension hooks for Bugzilla code
66
 
66
 
67
=head1 SYNOPSIS
67
=head1 SYNOPSIS
68
 
68
 
193
database when run.
193
database when run.
194
 
194
 
195
=back
195
=back
 
 
196
 
 
 
197
=head2 webservice
 
 
198
 
 
 
199
This hook allows you to add your own modules to the WebService. (See
 
 
200
L<Bugzilla::WebService>.)
 
 
201
 
 
 
202
Params:
 
 
203
 
 
 
204
=over
 
 
205
 
 
 
206
=item C<dispatch>
 
 
207
 
 
 
208
A hashref that you can specify the names of your modules and what Perl
 
 
209
module handles the functions for that module. (This is actually sent to 
 
 
210
L<SOAP::Lite/dispatch_with>. You can see how that's used in F<xmlrpc.cgi>.)
 
 
211
 
 
 
212
The Perl module name must start with C<extensions::yourextension::lib::>
 
 
213
(replace C<yourextension> with the name of your extension). The C<package>
 
 
214
declaration inside that module must also start with 
 
 
215
C<extensions::yourextension::lib::> in that module's code.
 
 
216
 
 
 
217
Example:
 
 
218
 
 
 
219
  $dispatch->{Example} = "extensions::example::lib::Example";
 
 
220
 
 
 
221
And then you'd have a module F<extensions/example/lib/Example.pm>
 
 
222
 
 
 
223
It's recommended that all the keys you put in C<dispatch> start with the
 
 
224
name of your extension, so that you don't conflict with the standard Bugzilla
 
 
225
WebService functions (and so that you also don't conflict with other
 
 
226
plugins).
 
 
227
 
 
 
228
=back
20
 
20
 
21
use Bugzilla;
21
use Bugzilla;
22
use Bugzilla::Constants;
22
use Bugzilla::Constants;
 
 
23
use Bugzilla::Hook;
23
 
24
 
24
# Use an eval here so that runtests.pl accepts this script even if SOAP-Lite
25
# Use an eval here so that runtests.pl accepts this script even if SOAP-Lite
25
# is not installed.
26
# is not installed.
29
 
30
 
30
Bugzilla->usage_mode(Bugzilla::Constants::USAGE_MODE_WEBSERVICE);
31
Bugzilla->usage_mode(Bugzilla::Constants::USAGE_MODE_WEBSERVICE);
31
 
32
 
 
 
33
my %hook_dispatch;
 
 
34
Bugzilla::Hook::process('webservice', { dispatch => \%hook_dispatch });
 
 
35
local @INC = (bz_locations()->{extensionsdir}, @INC);
 
 
36
 
32
my $response = Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI
37
my $response = Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI
33
    ->dispatch_with({'Bugzilla' => 'Bugzilla::WebService::Bugzilla',
38
    ->dispatch_with({'Bugzilla' => 'Bugzilla::WebService::Bugzilla',
34
                     'Bug'      => 'Bugzilla::WebService::Bug',
39
                     'Bug'      => 'Bugzilla::WebService::Bug',
35
                     'User'     => 'Bugzilla::WebService::User',
40
                     'User'     => 'Bugzilla::WebService::User',
36
                     'Product'  => 'Bugzilla::WebService::Product',
41
                     'Product'  => 'Bugzilla::WebService::Product',
 
 
42
                     %hook_dispatch
37
                    })
43
                    })
38
    ->on_action(\&Bugzilla::WebService::handle_login)
44
    ->on_action(\&Bugzilla::WebService::handle_login)
39
    ->handle;
45
    ->handle;

Loggerhead runs on Bazaar branches