--- Rolf Schaufelberger <rs at plusw.de> wrote:
> Hi, I'm just evaluating Maypole and I didn't find any hint where I can place
> actions which don't relate to a model.
>
> For instance :
> I use Plugin::I18N and want to place some links on my page like :
> <base>/setLang?lang=en in order to switch the language.
> Now how does a URL look like if I have no <table> and where can I place a
> method which calls the lang method ?
> Wouldn't it make sense to fall back
> BeerDB ? Right now nothing at all happens when is_applicable returns 0 ?
>
This is an excellent question.
I don't believe I'd want to fall back on BeerDB as that IS Maypole, the holy
$r.
Also i think this is true : <base>/plain_templates_can_go_here, so it would be
confusing.
What would ideal solution be? Would it do to be able to have plain Models that
don't relate to tables and put actions in them. so
<base/settings/setLang?lang=en would map to Settings::setLang($r) call.
If that works for you here's what you can do (using above as example):
Override class_of method in your base Model class to return what you want if
the "table" part is not actually a table. Then put "settings" in
config->display_tables or config->ok_tables (iether will work as all
display_tables get put in ok_tables ) so that it will pass the is_applicable
test. That should do it for you.
In Maypole, the model class is determined by the Maypole::Model::XXX::class_of
method. It takes the table part of url and returns a class. If model is CDBI
than it must be a real table and have a class associated with it or you don't
get a class.
In M::M::CDBI.pm this method looks like:
sub class_of {
my ( $self, $r, $table ) = @_;
return $r->config->loader->_table2class($table);
}
so you could make it something like:
sub class_of {
my ( $self, $r, $table ) = @_;
my $class = $r->config->loader->_table2class($table);
unless ($class) {
$class = "BeerDB::" . ucfirst($table);
$class = undef unless $class->isa("AppropriateClass");
}
return $class;
}
I'd be interested in a good general override for this if you come up with one.
=====
pjs
__________________________________
Do you Yahoo!?
Yahoo! Mail - Find what you need with new enhanced search.
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