2xlp has asked for the wisdom of the Perl Monks concerning the following question:
I have 3 websites that have been running off a proprietary mod_perl2 framework that I've been trying to standardize for eventual public distribution. ( and to answer some questions preemptively: I started work on this long before catalyst or jifty were around , when tt and mason were the only viable options )
Right now I'm trying to standardize a behavior in the dispatch class. I'm hoping someone can offer advice
The framework works pretty much like this:
Each instance of MyApp::PageController (ie: MyApp1 , MyApp2 ) has the following 2 vars:
My problem is:
Under the current design of the framework, the modules register against URI_enabled_fat/URI_enabled_upload as class variables, not object instance variables. Because of that, I have the getter/setter methods implemented in each MyApp::PageController class -- not in P2XLP::PageController-- I also have the function to build an ApacheRequest object in there too.
The issue is with migrating the getter/setters and builder into P2XLP::PageController -- I can't imagine any other way of accomplishing this other than an eval, which I try to avoid at all costs.
Can someone suggest a way to move the getter/setter/builder into the P_2XLP namespace, and still have it access the MyApp namespace for vars and calls efficiently and without using evals ?
Basically, I want to keep roughly this syntax:
but i want the functions and vars to be maintained here:package MyApp; my $aprObject= MyApp::PageController::build_apr_object(); package MyApp::Page::PhotoUpload; MyApp::PageController::register_enable_upload('/my/photos/upload'); MyApp::PageController::register_enable_fat('/my/photos/upload',100_000 +);
package MyApp::PageController; our (%URI_enabled_fat , %URI_enabled_upload); package P_2XLP::PageController; sub register_enable_upload{}; sub register_enable_fat{}; sub build_apr_object{};
I have no idea how to accomplish this in a logical way -- or even if its possible. what I'm trying to do is very counter-intuitive to many 'better' programming paradigms. Unfortunately, my design requirement is to maintain the variables as package/class variables within the subclass, while maintaing the functions in the super class.
If anyone can offer suggestions, I'd be very appreciative.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help migrating functionality from subclass to super class
by kyle (Abbot) on May 03, 2007 at 15:33 UTC | |
by 2xlp (Sexton) on May 03, 2007 at 18:01 UTC |