Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw


by SilasTheMonk (Chaplain)
on Aug 22, 2009 at 21:01 UTC ( #790611=perlquestion: print w/replies, xml ) Need Help??
SilasTheMonk has asked for the wisdom of the Perl Monks concerning the following question:

Would it be too much to ask for those who have actually used the various CGI::Application related modules to go in and review them in CPAN? I have used some and those I can review. But many of the others I cannot review. I may or may not like to use them - but quite frankly it is now too much trouble for me to try them.

The background is as follows: About a year ago now I selected CGI::Application as a web development framework based largely on information I found in perlmonks. I like this framework as it allows me to get to grips with the nitty gritty of web development and total control. However now I am hitting the limitations of it - particularly the lack of a model component. I believe I hit upon an elegant approach to this which I will in due course upload on CPAN and describe here. I could have done it the other way but since I want to use it now and I have some experience so I did not want to be deflected.

Edit: I have written reviews of CGI::Application, CGI::Application::Dispatch, CGI::Application::DBH. I ought to do DataForm::Validator and HTML::Template as well. But that would be about my limit.

Replies are listed 'Best First'.
Re: CGI::Application
by trwww (Priest) on Aug 22, 2009 at 22:24 UTC

    I selected CGI::Application as a web development framework based largely on information I found in perlmonks... However now I am hitting the limitations of it - particularly the lack of a model component.

    If you are looking for an ActiveRecord type pattern, check out Jifty.

    Personally, I feel that the lack of a defined model interface in CGI::App and Catalyst are strengths, not limitations. Just grab one of the ORM frameworks from CPAN and start using it.

      Just grab one of the ORM frameworks from CPAN and start using it.

      Yeah that is what I thought you are supposed to do. But when it came down it I did not feel it really solved my problems. I'll try to put a meditation together at some point on the subject.

      Also I have looked at Jifty and Catalyst but I keep deciding I really want to use CGI::Application.

Re: CGI::Application
by Anonymous Monk on Aug 23, 2009 at 14:21 UTC
    The only current Perl MVC tool with tight integration to a model is Jifty. With CGI::Application, you choose a tool like Rose::DB::Object or DBIx::Class for database work and primarily use that for your model.
Re: CGI::Application
by astroboy (Chaplain) on Aug 23, 2009 at 21:33 UTC

    What do you mean by "model"? Other responses refer to the model as the ORM library being used, but I use the term differently. For me, the model is the package where I place my business logic. It is more than just the database access component - it includes validation, data transformation and everything that doesn't simply include receiving web input or sending a new page to the user. This means my command-line interfaces use the same models as the web interfaces, and know nothing about the web.

    (BTW, I use DBIx::Class with my CGI::App apps)

      That sounds like Database plus ORM to me, especially one like DBIx::Class, where you can extend default DBIC classes to add transformation and validation (beyond what your database provides), or any other business process.
        Not all of your business logic (model) is necessarily DB related or should be part of your ORM. You might have to do things like FTP files, perform LDAP lookups and a myriad of other things. If you simply use your ORM in your controller (and a lot of web apps do this), then you've lost the ability to reuse your code outside of your CGI::App controller. (e.g. your boss or marketing dept now decide you need a batch or a SOAP interface to the same business logic, but your existing logic isn't reusable because it's all in the controller)

      I think astroboy has touched upon the problem here.

      Model means business logic encapsulated in a nice way. Typically this reduces to a series of products/clients/orders which can be modelled on a database. Hence the confusion between ORMs and models.

      I was having a different problem. There the business logic is about keeping the maintenance of the site down. The only recognizable object I can discern in the websites I'm currently looking at is the "page". I can reuse many templates across multiple templates but I was ending up with far too much code managing template parameters especially when a parameter can be used across several pages. Now what would an ORM give me? It would give me a different interface to the database (in fact another interface to learn) but it would not in itself have solved my problem.

      Edit: I am working on some modules that I am already confident solve my problems. I still need to do some work on them but the current code is in github under the repositories: cgi-application-pagelookup/cgi-application-plugin-pagelookup/cgi-application-plugin-pagelookup-sitestructure/cgi-application-pagelookup-lang.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://790611]
Front-paged by Arunbear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2016-09-25 11:12 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (469 votes). Check out past polls.