Difference between revisions of "Mod perl2 conversion"

From Dreamwidth Notes
Jump to: navigation, search
(New page: Here's a quick and dirty guide to things you will need to watch for when touching files and how to help us convert everything to Apache 2 / mod_perl 2 compatibility.<br /><br /><b>1) The R...)
 
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Here's a quick and dirty guide to things you will need to watch for when touching files and how to help us convert everything to Apache 2 / mod_perl 2 compatibility.<br /><br /><b>1) The Request Object</b><br /><br />Never call Apache->request.  If you need the request object, use BML::get_request() which will do the Right Thing to return the appropriate request object for you to mess with.<br /><br /><b>2) $ENV{LJHOME} is Dead</b><br /><br />You should use $LJ::HOME instead.  (Caveat: if you're writing a command line tool, you may need to use the environment variable, depending on what libraries you load... but for web context, always use $LJ::HOME!)<br /><br /><b>3) Methods become Hashes</b><br /><br />In a move that I don't particularly understand, now we must pluralize some things and treat most things like a hash.  If you are used to this:<br /><br />  $r->header_in("Host")<br />  $r->header_in("Host" => "bar");<br />  $r->notes("Something")<br /><br />Then you should now get used to this:<br /><br />  $r->headers_in->{Host};<br />  $r->headers_in->{Host} = "bar";<br />  $r->notes->{Something}<br /><br />Not much of a change.  This goes for all of the header calls: headers_in, headers_out, err_headers_in, err_headers_out, etc as well as notes and pnotes.  There are probably other changes I've missed that do this too.<br /><br /><b>4) $r->send_http_header defunct?</b><br /><br />I've yet to figure out a replacement for this function.  It seems to not be required anymore?  The modules seem to do the right thing, at least in all of the cases I've tried, without ever calling this.<br /><br /><b>5) ...?</b><br /><br />I'm sure I'm missing something.  But at this point, if you want to start grepping through dw-free for header_in, send_http_header, notes, etc and then start fixing it, go for it!  It's appreciated, as there are still many files that have these.<br /><br />As a second/other thought, I've been debating creating an LJ::Request object that we can use instead of Apache2::RequestRec (or whatever it is).  That way, if we ever need to change the way something works (i.e. upgrade to Apache 2.2 / mod_perl 2.2?) then we can change that one module.<br /><br />Opinions and discussion are welcome, of course!
+
Here's a quick and dirty guide to things you will need to watch for when touching files and how to help us convert everything to Apache 2 / mod_perl 2 compatibility.
 +
 
 +
== The Request Object ==
 +
 
 +
Never call Apache->request.  If you need the request object, use BML::get_request() which will do the Right Thing to return the appropriate request object for you to mess with.
 +
 
 +
== $ENV{LJHOME} is Dead ==
 +
 
 +
You should use $LJ::HOME instead.  (Caveat: if you're writing a command line tool, you may need to use the environment variable, depending on what libraries you load... but for web context, always use $LJ::HOME!)
 +
 
 +
== Methods become Hashes ==
 +
 
 +
In a move that I don't particularly understand, now we must pluralize some things and treat most things like a hash.  If you are used to this:
 +
 
 +
$r->header_in("Host")
 +
$r->header_in("Host" => "bar");
 +
$r->notes("Something")
 +
 
 +
Then you should now get used to this:
 +
 
 +
$r->headers_in->{Host};
 +
$r->headers_in->{Host} = "bar";
 +
$r->notes->{Something}
 +
 
 +
Not much of a change.  This goes for all of the header calls: headers_in, headers_out, err_headers_in, err_headers_out, etc as well as notes and pnotes.  There are probably other changes I've missed that do this too.
 +
 
 +
== $r->send_http_header defunct? ==
 +
 
 +
I've yet to figure out a replacement for this function.  It seems to not be required anymore?  The modules seem to do the right thing, at least in all of the cases I've tried, without ever calling this.
 +
 
 +
== ...? ==
 +
 
 +
I'm sure I'm missing something.  But at this point, if you want to start grepping through dw-free for header_in, send_http_header, notes, etc and then start fixing it, go for it!  It's appreciated, as there are still many files that have these.
 +
 
 +
As a second/other thought, I've been debating creating an LJ::Request object that we can use instead of Apache2::RequestRec (or whatever it is).  That way, if we ever need to change the way something works (i.e. upgrade to Apache 2.2 / mod_perl 2.2?) then we can change that one module.
 +
 
 +
Opinions and discussion are welcome, of course!
  
 
(Imported from http://community.stage2.dreamwidth.org/dw_dev/630.html)
 
(Imported from http://community.stage2.dreamwidth.org/dw_dev/630.html)
 +
 +
[[Category: Development Scratchpads]]

Latest revision as of 22:58, 25 March 2009

Here's a quick and dirty guide to things you will need to watch for when touching files and how to help us convert everything to Apache 2 / mod_perl 2 compatibility.

The Request Object

Never call Apache->request. If you need the request object, use BML::get_request() which will do the Right Thing to return the appropriate request object for you to mess with.

$ENV{LJHOME} is Dead

You should use $LJ::HOME instead. (Caveat: if you're writing a command line tool, you may need to use the environment variable, depending on what libraries you load... but for web context, always use $LJ::HOME!)

Methods become Hashes

In a move that I don't particularly understand, now we must pluralize some things and treat most things like a hash. If you are used to this:

$r->header_in("Host")
$r->header_in("Host" => "bar");
$r->notes("Something")

Then you should now get used to this:

$r->headers_in->{Host};
$r->headers_in->{Host} = "bar";
$r->notes->{Something}

Not much of a change. This goes for all of the header calls: headers_in, headers_out, err_headers_in, err_headers_out, etc as well as notes and pnotes. There are probably other changes I've missed that do this too.

$r->send_http_header defunct?

I've yet to figure out a replacement for this function. It seems to not be required anymore? The modules seem to do the right thing, at least in all of the cases I've tried, without ever calling this.

...?

I'm sure I'm missing something. But at this point, if you want to start grepping through dw-free for header_in, send_http_header, notes, etc and then start fixing it, go for it! It's appreciated, as there are still many files that have these.

As a second/other thought, I've been debating creating an LJ::Request object that we can use instead of Apache2::RequestRec (or whatever it is). That way, if we ever need to change the way something works (i.e. upgrade to Apache 2.2 / mod_perl 2.2?) then we can change that one module.

Opinions and discussion are welcome, of course!

(Imported from http://community.stage2.dreamwidth.org/dw_dev/630.html)