Tuesday, April 28, 2009

Bugzilla on Catalyst

One of the talks I submitted for this year's YAPC::NA is on converting legacy CGI and mod_perl applications to run on Catalyst instead, focusing on ways to get Catalyst in between existing code and the webserver so that incremental refactoring is a possibility, rather than "maintain as-is" or "rewrite entirely". I've done this successfully for elementalClinic, and I wanted to find a few more applications, maybe with a little more complexity (the nice way of saying "insanity", in this context), to try my hand at.

Unfortunately, I failed. Instead of a crazy application that would test the limits of my ability to get Catalyst into those hard-to-reach places, I found Bugzilla. (Yes, Bugzilla has some very strange internals, as someone who has hacked on it has told me, but it's not a mixture of three separate templating engines/application systems spread across your webserver's document root.) The end result was anticlimactic -- I got Bugzilla running on Catalyst's standalone http server after only a few hours and some patches to Catalyst::Controller::CGIBin and HTTP::Request::AsCGI. I ended up spending as much time on making it easy for other people to duplicate my results as I did on actual Bugzilla-specific code:

around wrap_perl_cgi => sub { my $next = shift; my $code = shift->$next(@_); sub { $Bugzilla::_request_cache = {}; $code->(); Bugzilla::_cleanup() }; };

This is just a quick hack, and for normal users of Bugzilla it's probably not a big deal. If the Bugzilla maintainers wanted to start converting to Catalyst, though, it would be a great place to start; for example, it'd be trivial now to set up some Catalyst actions to clean up Bugzilla's urls from e.g. /show_bug.cgi?id=17 to /show_bug/17. That could start out as simple as this:

sub show_bug :Local :Args(1) { my ($self, $c, $id) = @_; $c->request->params->{id} = $id; $c->go('/CGI_show_bug_cgi'); }

Later, more logic could be brought into Catalyst controllers, and eventually the old show_bug.cgi path could exist only for backwards compatibility. (I don't know that the Bugzilla team cares about this at all, but it is the kind of thing that people often would like to do with their own applications.)

(originally posted at OpenSourcery)

3 comments:

  1. Trong những năm gần đây, nhu cầu vận chuyển hàng đi Hà Nội ngày càng tăng cao. Theo đó, nhiều doanh nghiệp cần chuyển giao hàng hóa từ các tỉnh đến miền Trung.

    Tuy nhiên, hầu hết các doanh nghiệp đều gặp khó khăn trong việc tìm kiếm một công ty vận tải uy tín.

    Shuttle Cargo chúng tôi chuyên cung cấp các dịch vụ vận chuyển hàng đi Quảng Ngãi, vận chuyển hàng đi Bình Định, vận chuyển hàng đi Ninh Bình, vận chuyển hàng đi Quảng Ninh giá rẻ, cam kết giao đúng hẹn.

    Các bạn ủng hộ công ty mình nhé.

    ReplyDelete
  2. Thanks for sharing, nice post! Post really provice useful information!

    Giaonhan247 chuyên dịch vụ ship hàng từ mỹ về việt nam uy tín cũng như chia sẻ cách mua hàng trên amazon ship về việt nam và hướng dẫn cách mua hàng trên ebay từ khâu mua hàng mỹ online uy tín.

    ReplyDelete