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

Simon Flack sf@flacks.net
Fri, 03 Dec 2004 15:43:59 +0000


Peter Speltz wrote:
> First i replied just to sender, then replied to wrong list, now replying to
> correct list.  Sorry bout the duplicates.
> 
> 
> --- Dave Howorth <dhoworth@mrc-lmb.cam.ac.uk> wrote:
> 
> 
>>I wrote:
>>
>>>The first one is the classmetadata and I think you're both agreed that 
>>>it would be nice to have a means to turn it off. Somehow making it 
>>>evaluate lazily would be another option. Ironic perhaps, but turning it 
>>>into an object is my first thought :)
>>
>>'It' is very ambiguous. 'It' was obviously late at night. 'It' is 
>>classmetadata.cgi :)
>>
>>Sorry, Dave
>>
> 
> 
> I was thinking in the view::base where "IT" is created of doing something like
> this:
> 
>     . . .
>     cgi => $r->template_args{classmetadata_cgi} || { $class->to_cgi }
>     . . .
> 
> Then the model's sub can make them if it wants or set it to "1" to get none or
> do nothing and get them.

That looks good. But I'm not sure that it should be controlled by a 
template parameter. I was going to suggest something in $r->config, but 
that doesn't smell quite right either.

Perhaps it's something that you define on a class-by-class basis. Or 
perhaps you want different behaviour for different actions in a model?

I'd be tempted to change it to:

      cgi => sub { $class->to_cgi() },
or
      cgi => sub { $class->to_field(@_) },

That should work quite nicely for M::V::TT - there's no overhead unless 
you actually use it in the template. I imagine you'd need a different 
solution for Mason though.

--simonflk