[Maypole] Re: Maypole responding to requests very slowly (or, how to get just one associated record instead of getting the world)

From: Matt Adams (matt.adams at morcor.com)
Date: Thu Sep 30 2004 - 17:02:16 BST


Brian Glass wrote:

> I was counting on the section in the Class::DBI manual that said the
> Essential columns defaults to the All setting. I did try your suggestion
> and set up which columns should be essential. Since these changes things
> have gotten quite a bit speedier and the number of queries has dropped.

Hmmm... I must try this some time.

> Regardless, I do agree with Simon that something needs to change in the
> way Class::DBI::AsForm works in Maypole. It would make thinks
> considerably snappier.

A solution that I implemented yesterday involved addressing CDBI::AsForm's
desire to create a drop-down every time it encounters a has_a relationship.
To evade CDBI::AsForm's annoying habits I created a new View class, overloaded
the vars() method supplied by Maypole::View::Base and changed

cgi => { $class->to_cgi },

to

cgi => { to_cgi($class) },

where to_cgi is a method local to the new View class and looks something like:

sub to_cgi {
   my $class = shift;
   my (undef, $table_name) = split(/::/, $class);
   $table_name = lc $table_name;

   map {
     if
($rule{model}->{table}->{$table_name}->{fields}->{field}->{$_}->{is_accessible}
eq "TRUE") {
       $_ => $class->to_field($_);
     } else {
       $_ => $class->to_field($_, 'textfield');
     }
   } $class->columns;
}

Which works fine, since I happen to have an XML schema of the database where I
can specify nice attributes like is_accessible (for those columns that shouldn't
be editable by the end-user).

Unfortunately this is a nasty kludge and although it works fine for me it won't
extend very well to suit Maypole's generic framework ideology. I'd very much
like to see Simon's suggestion for "AsForm to return its own objects, which save
state and only hit the database when as_HTML is called on them."

Matt

-- 
Matt Adams <matt.adams at morcor.com>
Development Specialist
Morcor Solutions Inc. <http://www.morcor.com/>
(613) 354-2912 x228

GnuPG public key at <http://staff.morcor.com/~madams/> Key fingerprint: BED5 B4F7 CCF5 D7B5 7C56 0505 9A0A A0FB C937 5975

_______________________________________________ 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:56 GMT