Re: [Maypole] Why is moniker used instead of of table name when looking for table specific templates?

From: Peter Speltz (peterspeltz at yahoo.com)
Date: Wed Dec 29 2004 - 00:59:11 GMT


> > fom M::Manual::View--
> > Locating Templates
> > . . .
> > . . . This is where the
> > third directory comes in. The other directory, which May­
> > pole checks very first of all, is specific to the table
> > that you're viewing. So if you go to
> > "http://your.shop.com/basket/list", Maypole will look in
> > the basket directory first for a file called list, and
> > second in the custom directory for a site-wide list tem­
> > plate, and then fall-back to the factory directory for a
> > generic list template.
> >
> > The example in its simplicity is misleading as under default class dbi a
> table
> > like "note_card" will have a moniker like "notecard" and thus the directory
> > "notecard" will be searched.
>
> I'm not sure it's misleading, but it is ambiguous.
>

Misleading in this case:
package Football;
use base Class::DBI;
Football->table('fairy');

#Football->moniker is "football" which doesn't 'fairy'.
  
> > I'm not sure why moniker was used instead of table name. HOwever moniker
> is
> > overrideable so if you decide to change it, you'd need to change names of
> your
> > template directories.
>
> If we document the fact that the view uses the model's moniker for
> template paths then that would be expected behaviour.
>
> What are you overriding moniker() to? Or to put it another way, why is
> your overriden moniker() unsuitable for a template path?
>

Not sure yet :). Ideally i'd want to override it for use in templates the same
way column_names is used. So it could have any characters in it (especially
spaces.)

> Apart from the other reason(s) given for using moniker() over table(),
> it helps to decouple the view from the model.
> maypole model class at the moment which doesn't have tables.
>

That's the only decent argument i've heard for it yet. However, I think the
safest way is to have a model method dedicated soley to mapping to template
directories.

sub template_dir { return shift->moniker; }

That's database and moniker independent if you want
> --simonflk
>
> _______________________________________________
> maypole mailing list
> maypole at lists.netthink.co.uk
> http://lists.netthink.co.uk/listinfo/maypole
>

=====
pjs

                
__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250

_______________________________________________
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