The Register® — Biting the hand that feeds IT

BOFH: A change in tone

Geoff Richards

submitted direct from comment page 

You could spend a lot of time figuring out all the pieces of JavaScript on the client side and Perl on the server side in order to work out how to use Ajax in your code. However, this is Perl; we like to be a bit lazy. Thankfully, there's already a module on CPAN to take the pain out it: CGI::Ajax.

CGI::Ajax provides a small bit of infrastructure for your CGI programs. You tell it about some of your functions and it sets up JavaScript to call them and return the results to your page. You don't need to worry about writing the JavaScript to do this, because CGI::Ajax takes care of it. All you have to do is add some JavaScript calls to the functions defined in your script and let CGI::Ajax deal with the plumbing.

Geoff Richards

Some blurb from an article 

I've been working quite a bit with Django lately. One of the things I really love about Django is its URL mapping and how that ties into the request handling layer (which Django refers to as the "view"). Basically, you define a regex for a URL and associate it with a function to handle matching requests. When a request comes in that matches a URL regex, the request is passed off to the corresponding function in the URL mapping. Notice that I said "function" and not "method". The "view" (as Django refers to it, but what MVC frameworks would probably refer to as the "controller" layer) in Django is basically an event handler. It makes absolute sense for it to be a function rather than a method on some object.

As I've been enjoying the pragmatic design of Django's request mapping and handling, I started thinking back to my experience with CherryPy. In CherryPy, you define a class and certain methods of that class handle requests as they come in. The URL mapping is determined by attributes of an instance of that class, so it's really more implicit than Django's URL mappings are. I guess the two reasons CherryPy uses an OO approach in regard to its "controller" layer (which, CherryPy isn't a full MVC framework, but the term somewhat applies) is 1) this is probably the best way to accomplish URL mapping without having an explicit URL->handler map, and 2) it provides a way to logically structure your code.