>   As for the remaining of the question, I've been wondering for myself if
> there is a MVC (model-view-controller) framework for WWW publishing in
> Perl ? I gather there exist quite a few for Java, but I couldn't find
> anything significant under Perl.

Check out http://www.bivio.net/hm/why-bOP and http://petshop.bivio.net
The former motivates the MVC architecture.  The latter URL is a demo
of Sun's J2EE "blueprint" demo of a Pet Store implemented using bOP, a
perl application framework.  It's freeware and we use it to run a
large commercial website.

When you visit petshop.bivio.net, at the bottom of the page, you'll
see "Control Logic for This Page".  This is what the bOP agent
(controller) uses to determine if the incoming user can access the
page, what the page actually does (models and views), and any state
transitions (form next or cancel).  The links at the bottom of the
page go to the source of this application.

bOP also allows you to change the look-and-feel quite easily.  Compare
these two pages:

http://www.bivio.com/club_cafe/mail-msg?t=19341600003
http://ic.bivio.com/club_cafe/mail-msg?t=19341600003

They render the same content, but in two entirely different contexts.
Each look-and-feel is described in a single file, which contains
color, font, URL, text, and view mappings.

bOP is about 250 classes including the Pet Shop demo.  It uses Oracle
or Postgres, but it should be easy to port to other databases. You can
also build a "static" site, e.g. http://www.bivio.net which doesn't 
require a database.

<SOAPBOX>
The J2EE architecture implements MV, not MVC imiho.  Here's one of my
favorite quotes from Sun's site:

  It is important to understand that Model, View, and Controller are 
  usually not represented by individual classes; instead, they are 
  conceptual subdivisions  of the application. 

This is true for J2EE, but not true for MVC frameworks.  J2EE's
control flow is not a distinct element.  JSPs are usually full of
business logic.  The whole MVC concept passed J2EE by.

Even when you look at "Model 2 Methodology" (promoted by Apache
Jakarta Turbine), the code is a mess.  Here's a snippet from the
reference article on Model 2:

  public void doPost (HttpServletRequest req, HttpServletResponse res)
                          throws ServletException, IOException {
  HttpSession session = req.getSession(false);
  if (session == null) {
       res.sendRedirect("http://localhost:8080/error.html";);
  }
  Vector buylist= (Vector)session.getValue("shopping.shoppingcart");
  [...]
  if (!action.equals("CHECKOUT")) {
  if (action.equals("DELETE")) {
  [...]
  String url="/jsp/shopping/EShop.jsp";
  [...]
  String url="/jsp/shopping/Checkout.jsp";

The excerpt is from a single method in which they mix sessions, port
numbers, hosts, error pages, URLs, button values, etc.

The JSP is no better and contains lines like:

  <option>Yuan | The Guo Brothers | China | $14.95</option>
  <b>Quantity: </b><input type="text" name="qty" SIZE="3" value=1>
  <input type="submit" value="Delete">  
  <input type="hidden" name="action" value="DELETE">

Note that "DELETE" in the JSP must be the same as "DELETE" in the
Java.  Nothing is checking that.  You only know that the code doesn't
work when someone hits the page.  In this particular example, if you
mispell DELETE in either place, the code does something, and 
doesn't issue an error.

So much for Model 2.  I wonder what Model 3 will be like. ;-)

Sorry, had to get that off my chest...
</SOAPBOX>

Cheers,
Rob

Reply via email to