Nathan Byrd wrote:
Good work, Nathan!Hi all,Below is an initial version of a patch against the latest CVS version of RegistryCooker.pm (and RegistryLoader.pm) to support better subclassing, including the ability to access module data from RegistryCooker in a clean way and to add private data to subclasses, without relying on the underlying array implementation (below my patch is the original message written to the mod_perl list and Stas Bekman's response to provide the context for this.) The biggest part of this patch is from a change to the constants in RegistryCooker to be _REQ instead of REQ, etc, because I couldn't have two subs with the same name, and these constants are really internal data anyway, especially if you want to be able to not rely on RegistryCooker being implemented as an array. Let me know if this is a problem, I can also do it the other way around (another possibility would be to change them instead to something like REQ_IDX or something, but its kinda wordy). To use this in a subclass, I call "public" with this names of the variables I want to use for my subclass, then use them like normal: eg: public qw( PAR_MEMBER ... ); ... $self->PAR_MEMBER(<value>); # Set a value ... $something = $self->PAR_MEMBER; #Get a value We can also access the base class data in the same fashion: my $r = $self->REQ; I left the original constant usage inside RegistryCooker for performance (no need to do an extra sub call inside RegistryCooker itself). Please take a look at this and let me know what you think - I've tested it under my configuration with the latest CVS and a now much nicer looking version :-) of my Apache::PAR module as well as some simple Registry scripts. If this patch is acceptable I'll also send another patch to add the appropriate tests to the test suite and add a section about subclassing RegistryCooker to the porting guidelines and RegistryCooker docs.
The patch needs some minor tweaking to conform with our coding style, but overall it looks good. Though before we move on with this, won't it be simpler to use the 'fields' pragma?
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
