Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: RFC: Apache::Controller

by revdiablo (Prior)
on Dec 03, 2004 at 18:30 UTC ( #412224=note: print w/ replies, xml ) Need Help??


in reply to Re: RFC: Apache::Controller
in thread RFC: Apache::Controller

Thanks for your comments! I will definitely give them some more thought, but here are some of my initial reactions.

First things first: I don't think the "perfect" framework for web applications has been invented yet

I agree, but before we start off with the wrong idea, I'm not really attempting to build an entire framework. I'm only trying to make one part of it -- the controller. And a very limited controller at that.

One thing I don't like is that the template is too tightly coupled to the action - it's entirely possible that several related actions want to use the same template

This is true, and probably something I'll put in eventually. I could easily extend the contructor to take in template names for the actions, along with the module names. I'd keep the default behavior of template name being the same as action name, though, because it's quite convenient.

or for an action to have more than one resulting template.

I'm not so sure about this. I would either make the template flexible enough to handle everything the action needs, or to create two different actions.

Also, I'm sceptical about using classes to describe actions.

Well, I don't know if this has any bearing on your argument or not, but I'm not really using classes. Just plain old Perl packages. The main purpose they serve is to contain the handler subroutines, but they also make for a nice separation at the filesystem level, which I like.

Lastly, I would like more hooks in the code - some place to do general setup or session management would be nice for instance

This is a perfect example of why I don't like the name I've chosen. I'm not attempting to write an end-all, be-all solution, just something that lets me get some stuff done. These features would definitely be useful in many applications, but for what I'm doing, they'd just get in the way. Maybe there's a better way to name my module that conveys that message?


Comment on Re^2: RFC: Apache::Controller
Download Code
Re^3: RFC: Apache::Controller
by Joost (Canon) on Dec 03, 2004 at 18:58 UTC
    or for an action to have more than one resulting template.
    I'm not so sure about this. I would either make the template flexible enough to handle everything the action needs, or to create two different actions
    But how do you know what action is going to get run, then?

    See my example about form validation above. Basically, you recieve data from "form 1" ( to an action) , and you want to either a) go back to a form 1. b) proceed to form 2, and try to submit that (repeat for form 2, 3 etc.).

    In your system you will need to include form 1 and form 2 into one template just because the action can't choose the template for you. It's certainly possible to do that, but I think it will get ugly very quickly.

      Basically, you recieve data from "form 1" ( to an action) , and you want to either a) go back to a form 1. b) proceed to form 2, and try to submit that (repeat for form 2, 3 etc.).

      I would make Form 1 and Form 2 two separate actions. Form 1 would submit to itself. If stuff was missing, it would return parameters that let the Form 1 template give an appropriate error message. If everything was fine, it would redirect to Form 2.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://412224]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-09-01 20:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (17 votes), past polls