Re: [Maypole] specifying different names for classmetadata elements

From: Dave Howorth (dhoworth at mrc-lmb.cam.ac.uk)
Date: Mon Dec 06 2004 - 11:45:43 GMT


Your Name wrote:
> Hi, i want to specify different values for
> classmtadata.plural and classmetadata.moniker so that
> without touching the templates i can get better values
> for these fields than what Maypole gives by getting
> them from the table names.
>
> How do i do this?

Sorry, but I don't believe it's sensible to try. Maypole's generation of
names for output is, IMHO, a mess. I believe you'd do much better to
modify the templates to do what you want, for at least two reasons: (1)
what you propose may not entirely solve your problem (see below) and (2)
it's not something that's particularly easy to do - you'll need to
override the whole of classmetadata in template_args or modify the View
class, though this may get easier in the next release.

I'm working on a different Maypole loader for various reasons, but one
is to address this problem. It includes a separate name mangling module.
I intend to publish more details in the next day or two.

FWIW, here's my understanding of how Maypole generates names:

ClassNames are generated from SQL table_names by
Class::DBI::Loader::Generic::_table2class() which is called in two
places: Maypole::Model::CDBI::class_of() and
Class::DBI::Loader::mysql::_load_classes().

_table2class() converts table names to class names, by upper-casing the
first letter of words and removing underscores, then prefixing with the
namespace. (*** I think Class:DBI::Autoloader does a slightly better job
because it deals with any non-alphanumeric separator, not just
underscores, and in any case I need to change this to handle plurals ***)

Table visibility is determined by config->{display_tables} which makes
all tables visible by default.

Displayed table names are sometimes (addnew box) obtained from the
moniker and moniker_plural methods of the table's model class, which are
generated from the class's name by UNIVERSAL::moniker, which is used by
Class::DBI. In particular, this means that if your table names are
plural then moniker_plural will be singular!

At other places (navbar, frontpage), displayed table names are obtained
from the template variable config.display_tables, which defaults to the
list of raw SQL table names generated by the loader, but can be set
explicitly in the config by the application's controller class.

Column visibility and order is determined by
Maypole::Model::Base::display_columns(), which makes all columns visible
and displayed in alphabetical order unless overridden.

Displayed column names are generated from SQL column names by
Maypole::Model::Base::column_names()

Cheers, Dave

_______________________________________________
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