Re: [Maypole] Multiple controllers

From: Dave Howorth (Dave.Howorth at acm.org)
Date: Wed Jan 12 2005 - 21:56:05 GMT


Vsevolod (Simon) Ilyushchenko wrote:
> How would I deal with the following, in Maypole or otherwise?

I'm not sure I've understood your question, so forgive me if I go off at
a tangent.

> Suppose I have to enter a date on several web pages. I include a
> template for displaying dates into the templates for my web pages, and I
> have a DateController class that is created and owned by each page's
> controller.

I'm not sure what the page controller is here? I guess the corresponding
entity in Maypole would be the do_edit action of the page's model class?
If so, the Model, View and StandardTemplate chapters of the manual have
some explanation of how that works in Maypole.

> However, I have to exchange data (day/month/year) between the main model
> instance and the the DateController instance. I am doing this pretty
> haphazardly, and I wonder if someone wrote any standard ways of
> accomplishing this.

For dates in particular, and also as an example of the general case,
Maypole relies on the model's facilities (i.e. CDBI). You would pick a
suitable class to model a date (Time::Piece is the usual example) and
tell CDBI and friends to use it by calling has_a (see the Class::DBI
docs) and untaint_columns (see Class::DBI::FromCGI and CGI::Untaint).

Maypole has the concept of component requests (i.e. bits of pages with
different models etc) on output but AFAIK it doesn't have a standard way
to do that on input. But you could easily code the top-level responding
action to call component actions to deal with parts of the input. The
interface would be by side-effect - changed state in the model - unless
you wanted to code specific features into the method calls. But this
sounds OK; going back to the object in the model that represents your
date and asking it for its value seems like the right thing to do.

Cheers, Dave

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.6.10 - Release Date: 10/01/05

_______________________________________________ maypole mailing list maypole at lists.netthink.co.uk http://lists.netthink.co.uk/listinfo/maypole



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT