Re: modperl/ASP and MVC design pattern
[EMAIL PROTECTED] wrote: > > Francesco, I believe that Ian was joking, hence the yikes before the name, > > so the above post is the documentation! > > > > Ed > > > > .. so the best environment for the MVC++ design pattern is parrot/mod_parrot :) > http://www.oreilly.com/news/parrotstory_0401.html > > Thanks > Francesco > Exactly! Wasn't Ian the one responsible for the mod_parrot MVC++ API? ed
Re: modperl/ASP and MVC design pattern
Quoting ed phillips <[EMAIL PROTECTED]>: > Francesco Pasqualini wrote: > > > - Original Message - > > From: <[EMAIL PROTECTED]> > > To: "Francesco Pasqualini" <[EMAIL PROTECTED]> > > Cc: <[EMAIL PROTECTED]> > > Sent: Friday, April 20, 2001 8:11 PM > > Subject: Re: modperl/ASP and MVC design pattern > > > > > > > > You can (I have) accomplish this with mod_perl and HTML::Mason, Mason's > > > root level autohandler can play the role of the JSP model 2 > > > "controller servlet": dispatching logic processing to Perl objects (er, > > > beans) and "forwarding" to a view (with the Mason $m->call_next or > > > $m->comp mechanisms). I think the Apache::Dispatch stuff can also > > > perform this role (haven't played with it to say for certain). I'll > > > qualify this by saying MVC is not a end in itself, there are a lot of > > > modern requirements for flexible branding, client form factor > appropriate > > > and locale specific presentations that require the view/controller part > to > > > be a lot smarter than the traditional concepts of MVC that I've seen > call > > > for. I've been referring to these needs in my own engineering > discussions > > > as (yikes) MVC++ :) > > > > ... this is really interesting, can you point me to documentation about > > "MVC++" > > thanks > > Francesco > > Francesco, I believe that Ian was joking, hence the yikes before the name, > so > the above post is the documentation! > > Ed > .. so the best environment for the MVC++ design pattern is parrot/mod_parrot :) http://www.oreilly.com/news/parrotstory_0401.html Thanks Francesco --- This mail sent through the IMP demo site: demo.horde.org Find out more at http://www.horde.org/imp/
Re: modperl/ASP and MVC design pattern
Francesco Pasqualini wrote: > - Original Message - > From: <[EMAIL PROTECTED]> > To: "Francesco Pasqualini" <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Friday, April 20, 2001 8:11 PM > Subject: Re: modperl/ASP and MVC design pattern > > > > > You can (I have) accomplish this with mod_perl and HTML::Mason, Mason's > > root level autohandler can play the role of the JSP model 2 > > "controller servlet": dispatching logic processing to Perl objects (er, > > beans) and "forwarding" to a view (with the Mason $m->call_next or > > $m->comp mechanisms). I think the Apache::Dispatch stuff can also > > perform this role (haven't played with it to say for certain). I'll > > qualify this by saying MVC is not a end in itself, there are a lot of > > modern requirements for flexible branding, client form factor appropriate > > and locale specific presentations that require the view/controller part to > > be a lot smarter than the traditional concepts of MVC that I've seen call > > for. I've been referring to these needs in my own engineering discussions > > as (yikes) MVC++ :) > > ... this is really interesting, can you point me to documentation about > "MVC++" > thanks > Francesco Francesco, I believe that Ian was joking, hence the yikes before the name, so the above post is the documentation! Ed
Re: modperl/ASP and MVC design pattern
- Original Message - From: <[EMAIL PROTECTED]> To: "Francesco Pasqualini" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Friday, April 20, 2001 8:11 PM Subject: Re: modperl/ASP and MVC design pattern > > You can (I have) accomplish this with mod_perl and HTML::Mason, Mason's > root level autohandler can play the role of the JSP model 2 > "controller servlet": dispatching logic processing to Perl objects (er, > beans) and "forwarding" to a view (with the Mason $m->call_next or > $m->comp mechanisms). I think the Apache::Dispatch stuff can also > perform this role (haven't played with it to say for certain). I'll > qualify this by saying MVC is not a end in itself, there are a lot of > modern requirements for flexible branding, client form factor appropriate > and locale specific presentations that require the view/controller part to > be a lot smarter than the traditional concepts of MVC that I've seen call > for. I've been referring to these needs in my own engineering discussions > as (yikes) MVC++ :) ... this is really interesting, can you point me to documentation about "MVC++" thanks Francesco
Re: modperl/ASP and MVC design pattern
> I' m using UniquePackages and because subs name conflict I need to put the > subs in the asp pages. > Can I still use initialization of global vars in the > global.asa/Spript_OnStart (as you suggest) ? > ...so the ASP/$Server->Transfer() is the equivalent of JSP/forward > I don't know if transfer is quite the same, $Response->Redirect() might be more similar depending whether its an internal or external redirect. You could hijack part of the ASP object namespace for your uses like: $Request->{CX}{name} = 'hello'; or hijack a var in the main:: package $main::CX->{name} = 'hello'; You could also lose your reliance on UniquePackages by putting your subs into the global.asa. You might also init an object which inits into context globally which you could reset every Script_OnStart, like # in script <% my $cx = CX->new; %> # in CX.pm; this is probably similar to Class::Singleton use vars qw($CX); $CX = {}; sub new { bless $CX } # in global.asa use CX; sub Script_OnStart { $CX::CX = {}; } -- Josh
Re: modperl/ASP and MVC design pattern
- Original Message - From: "Joshua Chamas" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Saturday, April 21, 2001 3:54 AM Subject: Re: modperl/ASP and MVC design pattern > [EMAIL PROTECTED] wrote: > > > > To avoid passing many parameters to the subs I become using a $cx (cx stand for > > context) global hash containig everything the subs needed, passed to each sub. > > > >page test.asp > >$cx = {}; > >$cx->{'name'} = 'default name'; > >$cx->{'age'} = 30; > >... > > Try this, > > # in global.asa > use vars qw($cx); # set up $cx for global use > sub Script_OnStart { > $cx = {}; # initialize per request > } > > # in script > sub HelloWorld { > $cx->{name} = 'hello'; > } > > This will work, but I'd recommend you move your subs to > global.asa, which is your central module for your scripts. I' m using UniquePackages and because subs name conflict I need to put the subs in the asp pages. Can I still use initialization of global vars in the global.asa/Spript_OnStart (as you suggest) ? ...so the ASP/$Server->Transfer() is the equivalent of JSP/forward Thanks Francesco > > And then you can use $Server->Transfer() to change > the file executing midstream. > > --Josh >
Re: modperl/ASP and MVC design pattern
[EMAIL PROTECTED] wrote: > > To avoid passing many parameters to the subs I become using a $cx (cx stand for > context) global hash containig everything the subs needed, passed to each sub. > >page test.asp >$cx = {}; >$cx->{'name'} = 'default name'; >$cx->{'age'} = 30; >... Try this, # in global.asa use vars qw($cx); # set up $cx for global use sub Script_OnStart { $cx = {}; # initialize per request } # in script sub HelloWorld { $cx->{name} = 'hello'; } This will work, but I'd recommend you move your subs to global.asa, which is your central module for your scripts. And then you can use $Server->Transfer() to change the file executing midstream. --Josh
Re: modperl/ASP and MVC design pattern
Quoting Joshua Chamas <[EMAIL PROTECTED]>: > > Francesco Pasqualini wrote: > > > > an interesting feature of JSP is the possibility to use the MVC design > pattern (INPUT/OUTPUT/LOGIC separation) > > This is obtained with the "forward" instruction. > > How the MVC design pattern can be implemented in the mod_perl (and > specifically Apache::ASP) architecture ? > > > > If you do use Apache::ASP in this way, how are you doing it. > I don't know much about what you are going after, so it would > be neat to hear how you accomplish it. ...mmh... Developing an Apache::ASP application I encountered the problem/feature that it is not possible to use global variables inside subs in a page. For example: page test.asp $name='default name'; ... HelloWord(); sub HelloWord{ print $name; ## WRONG using global var is incosistent in mod_perl } The correct approach if you have sub in a asp Page is to pass it everything it need: page test.asp $name='default name'; ... HelloWord($name); sub HelloWord{ my $name = shift; #OK print $name; ## OK $name is not global } To avoid passing many parameters to the subs I become using a $cx (cx stand for context) global hash containig everything the subs needed, passed to each sub. page test.asp $cx = {}; $cx->{'name'} = 'default name'; $cx->{'age'} = 30; ... HelloWord($cx); ... sub HelloWord{ my $cx = shift; my $name = $cx->{'name'}; #OK print $name; ## OK $name is not global } ...at the end of the work I realized that the idea of such a context is exactly what it is used in MVC tools like: - JSP templates, - www.webmacro.org, - jakarta.apache.org/velocity, - www.freemarker.org. But in such a way I've done a MVC architecture in a single page, where a part of the page is the View and a part is the Controller(logic). If Apache::ASP will support the 'forward' directive we could start developing MVC application in a way similar to the JSP world. Useful Links to MVC documentations are in: http://jakarta.apache.org/velocity/ymtd/ymtd.html JSP Specification: http://java.sun.com/aboutJava/communityprocess/first/jsr053/jsp12.pdf Francesco > > --Josh > > _ > Joshua Chamas Chamas Enterprises Inc. > NodeWorks >> free web link monitoring Huntington Beach, CA USA > http://www.nodeworks.com1-714-625-4051 > --- This mail sent through the IMP demo site: demo.horde.org Find out more at http://www.horde.org/imp/
Re: modperl/ASP and MVC design pattern
At 10:01 AM 4/20/01 -0700, Perrin Harkins wrote: >On Fri, 20 Apr 2001, Francesco Pasqualini wrote: > > But are there in the mod_perl architecture some guidelines and/or > > frameworks that encourages the MVC design patern ? I think that > > Apache::ASP could be (for example) the right tool, adding the > > "forward" feature. > >The forward feature looks like an ordinary include to me. Is there any >real difference between that and the Apache::ASP version? > >$Response->Include("filename.inc", @args); I don't know what Apache::ASP is doing in this case, but the Forward in JSPs is not a simple include. A forward is literally forwarding the request from one JSP to another JSP page. As long as the previous JSP page has not output any data (and is pure model/controller code) then the forward can be made to any JSP page that has its own content-type and data to display. This is how a pure JSP app can be made MVC. You write beans which represent the model, one JSP for the main app controller which dynamically determines the actual full display JSP (the view) to forward to. A simple include would not care, for example, if the content-type or a header in the first page had already been output. In the case of JSP, if the content gets commited in one page, forward is a directive that will no longer work I believe. Later, Gunther
Re: modperl/ASP and MVC design pattern
At 15:44 20.04.2001 +0200, you wrote: >an interesting feature of JSP is the possibility to use the MVC design >pattern (INPUT/OUTPUT/LOGIC separation) >This is obtained with the "forward" instruction. >How the MVC design pattern can be implemented in the mod_perl (and >specifically Apache::ASP) architecture ? http://www.catstep.de/zobel/post2redirect.html The essence is if you respect GET/POST semantics: All scripts that process POST requests must always end up doing redirects. Joachim -- "... ein Geschlecht erfinderischer Zwerge, die fuer alles gemietet werden koennen."- Bertolt Brecht - Leben des Galilei
Re: modperl/ASP and MVC design pattern
At 17:57 20.04.2001 +0200, you wrote: >- Original Message - >From: "Brett W. McCoy" ><<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> >To: "Francesco Pasqualini" ><<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> >Cc: <<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> >Sent: Friday, April 20, 2001 5:32 PM >Subject: Re: modperl/ASP and MVC design pattern > >I think that Apache::ASP could be (for example) the right tool, adding the >"forward" feature. The forward seems to be an internal_redirect (Apache API, Server Core Functions). But IMHO a redirect is much better. If you have a page that simpy displays data, a single Page will do. And if you change server state, a redirect is preferable because it is "reload stable". Joachim -- "... ein Geschlecht erfinderischer Zwerge, die fuer alles gemietet werden koennen."- Bertolt Brecht - Leben des Galilei
Re: modperl/ASP and MVC design pattern
You can (I have) accomplish this with mod_perl and HTML::Mason, Mason's root level autohandler can play the role of the JSP model 2 "controller servlet": dispatching logic processing to Perl objects (er, beans) and "forwarding" to a view (with the Mason $m->call_next or $m->comp mechanisms). I think the Apache::Dispatch stuff can also perform this role (haven't played with it to say for certain). I'll qualify this by saying MVC is not a end in itself, there are a lot of modern requirements for flexible branding, client form factor appropriate and locale specific presentations that require the view/controller part to be a lot smarter than the traditional concepts of MVC that I've seen call for. I've been referring to these needs in my own engineering discussions as (yikes) MVC++ :) On Fri, 20 Apr 2001, Francesco Pasqualini wrote: > an interesting feature of JSP is the possibility to use the MVC design pattern >(INPUT/OUTPUT/LOGIC separation) > This is obtained with the "forward" instruction. > How the MVC design pattern can be implemented in the mod_perl (and specifically >Apache::ASP) architecture ? cheers, -Ian -- Ian Kallen <[EMAIL PROTECTED]> | AIM: iankallen
Re: modperl/ASP and MVC design pattern
> Francesco Pasqualini wrote: > > an interesting feature of JSP is the possibility to use the MVC design pattern >(INPUT/OUTPUT/LOGIC separation) > This is obtained with the "forward" instruction. > How the MVC design pattern can be implemented in the mod_perl (and specifically >Apache::ASP) architecture ? > I don't know about MVC design patterns, but Apache;:ASP has these features which may help, of which $Server->Transfer() is probably your closest match to the forward instruction: $Server->Transfer($file) Transfer control to another script for execution with current script context including current $Session $Application, etc. my $data_ref = $Response->TrapInclude($file, @args) print/$Response->Write() output of script does not go straight to client browser, instead returns output in a scalar reference that you may post process as you like $Response->Include($file, @args) Like , but @args are available in script in @_ $Server->Execute() is an alias for $Response->Include() Script_OnStart, Script_OnEnd, Script_OnFlush events Various events called, if defined in your global.asa, during the life of the script execution. Script_OnStart can be used to set globals available to scripts, or manage things such as site wide authentication control Script_OnFlush is useful for post processing data going to the client browser in a global way. XMLSubs Ability to create XML tags which are handled by perl code execution. The nice thing is that embedded tags pass their output as an argument to parent XMLSubs, for example: The my::input sub would execute then return its HTML to the my::form sub in a calling structure like: &my::form(\%args, $html = &my::input(\%other_args)); -- Josh _ Joshua Chamas Chamas Enterprises Inc. NodeWorks >> free web link monitoring Huntington Beach, CA USA http://www.nodeworks.com1-714-625-4051
Re: modperl/ASP and MVC design pattern
On Fri, 20 Apr 2001, Francesco Pasqualini wrote: > But are there in the mod_perl architecture some guidelines and/or > frameworks that encourages the MVC design patern ? I think that > Apache::ASP could be (for example) the right tool, adding the > "forward" feature. The forward feature looks like an ordinary include to me. Is there any real difference between that and the Apache::ASP version? $Response->Include("filename.inc", @args); In addition to Apache::PageKit, you might want to check out the documentation for Template Toolkit, especially http://www.template-toolkit.org/docs/default/index.html. - Perrin
Re: modperl/ASP and MVC design pattern
> But are there in the mod_perl architecture some guidelines and/or frameworks > that encourages the MVC design patern ? Apache::PageKit is a MVC based framework. You can find it on CPAN here: http://cpan2.org/Asset/display?dist=Apache-PageKit I wrote an article on it for take23: http://take23.org/articles/2001/01/04/pagekit.xml
Re: modperl/ASP and MVC design pattern
- Original Message -From: "Brett W. McCoy" <[EMAIL PROTECTED]>To: "Francesco Pasqualini" <[EMAIL PROTECTED]>Cc: <[EMAIL PROTECTED]>Sent: Friday, April 20, 2001 5:32 PMSubject: Re: modperl/ASP and MVC design pattern> On Fri, 20 Apr 2001, Francesco Pasqualini wrote:>> > an interesting feature of JSP is the possibility to use the MVC design> > pattern (INPUT/OUTPUT/LOGIC separation) This is obtained with the> > "forward" instruction. How the MVC design pattern can be implemented> > in the mod_perl (and specifically Apache::ASP) architecture ?[...]>> Finally, my top-level layer was a simple script (this wasn't a class per> se) that was a 'driver' for the everything else -- I actually use a> modified form of Recipe 19.12 in the Perl cookbook. I maintain state> between page access through a single state variable, and have a hash that> manages my data class and the display class, and the state variable is> used to determine what 'page' to display, and handles top-level error> handling.this is very interesting ... and another good reason to buy thePerlCookBook.But are there in the mod_perl architecture some guidelines and/or frameworksthat encourages the MVC design patern ?I think that Apache::ASP could be (for example) the right tool, adding the"forward" feature. http://java.oreilly.com/news/jsptips_1100.html (explanation of the"forward" action)ThanksFrancesco>> -- Brett> http://www.chapelperilous.net/btfwk/> > genealogy, n.:> An account of one's descent from an ancestor> who did not particularly care to trace his own.> -- Ambrose Bierce>>>
Re: modperl/ASP and MVC design pattern
On Fri, 20 Apr 2001, Francesco Pasqualini wrote: > an interesting feature of JSP is the possibility to use the MVC design > pattern (INPUT/OUTPUT/LOGIC separation) This is obtained with the > "forward" instruction. How the MVC design pattern can be implemented > in the mod_perl (and specifically Apache::ASP) architecture ? MVC isn't dependent on any particular language, it's a top level design for your application. I have used something similar to the MVC model using just CGI.pm & DBI/DBD. The basic idea is to decouple your data model from the display of that data. It's probably not textbook accurate MVC, but it borrows heavily from the architecture. I created a wrapper class for by database functionality (didn't sub-class DBI, but encapsulated it and the specifics of my data retrieval in the class). This class had hogh-level methods like $data->get_id, $data->list_ids, etc. I have used this same class with both PostgreSQL and MySQL, and the top-level interface didn't have to change, even though the underlying data structures did because of differences between PostgreSQL and MySQL (for instance, I could't use views or referential integrity contraints in MySQL). Then I created a display class that handled displaying stuff on the browser -- also encapsulating the CGI module in high-level methods like $disp->registration_form, $disp->error_page, etc. Again, here, I used this class where I had a newer version of CGI, but had to retrofit the class to a system that used an older version of CGI, so I had to recode a couple of methods using raw HTML and here docs, since the older system didn't have CGI methods available in the newer version. Finally, my top-level layer was a simple script (this wasn't a class per se) that was a 'driver' for the everything else -- I actually use a modified form of Recipe 19.12 in the Perl cookbook. I maintain state between page access through a single state variable, and have a hash that manages my data class and the display class, and the state variable is used to determine what 'page' to display, and handles top-level error handling. -- Brett http://www.chapelperilous.net/btfwk/ genealogy, n.: An account of one's descent from an ancestor who did not particularly care to trace his own. -- Ambrose Bierce
modperl/ASP and MVC design pattern
an interesting feature of JSP is the possibility to use the MVC design pattern (INPUT/OUTPUT/LOGIC separation) This is obtained with the "forward" instruction. How the MVC design pattern can be implemented in the mod_perl (and specifically Apache::ASP) architecture ? Thanks Francesco