Re: inflating columns to objects

[prev] [thread] [next] [Date index for 2004/10/27]

From: Dave Howorth
Subject: Re: inflating columns to objects
Date: 13:24 on 27 Oct 2004
Drew Taylor wrote:
> I'm a bit confused (I'm also not a current maypole user either so...).
> But if the column is just text, and AsForm will decide what widget to
> use, then why do you need to inflate it? Inflating is usually done
> when you have an object you'd like to present in a special way (ie a
> Date object should display in your chosen format). Are you saying you
> want the text itself formatted into lines? If so, why not just let the
> form widget handle it?

Hi Drew,

Sorry for confusing you. I simplified the description of the formatting 
because it isn't relevant to the problem I'm trying to solve and I 
didn't want to confuse everybody with irrelevant detail. Since you're 
interested, what I'm trying to do is format the string into fixed length 
lines (not whatever width the widget happens to be). Then I want to put 
numbers at the start and end of the line indicating the character 
position in the string. It's a common way to present biological 
sequences. I hope that clears up that confusion.

> As for how to inflate something it's very simple:
> 
> MyClass->columns(Essential=>qw(...my_col...));
> MyClass->has_a(my_col => MyInflator, inflate=>\&MyInflator::inflate);
> # the subref can be located in any package - just use a fully
> qualified function name
> 
> package MyInflator;
> 
> sub inflate {
>   my $value = shift;
>   # format it...
>   return $formatted;
> }

OK, this is an alternative style of definition. When I substitute this 
code for my code, I see the following changes:

   - the inflate method does get called (in my code, my display method
     followed by my new method got called), but
   - the string that is displayed on the Maypole list page is the
     original string, not the 'inflate'd one (in my code it was the
     'display'ed string).
   - there IS now a string displayed on the edit page (i.e the AsForm
     generated text) but it too is the original database string (in my
     code, there's no widget at all.)

So this doesn't get the modified text on the page at all :(  I guess the 
reason is not because you used a different style of setting up the 
inflate method, but because you didn't overload stringification. Your 
method causes the formatted text to be stored in the object, whereas 
mine stores the database string and formats on output.

Oh, well, back to the debugger. I've stepped all the way through it once 
but didn't see anything I understood to be the problem. I'll try again.

Cheers, Dave

(message missing)

inflating columns to objects
Dave Howorth 16:23 on 26 Oct 2004

Re: inflating columns to objects
Drew Taylor 16:30 on 26 Oct 2004

Re: inflating columns to objects
Dave Howorth 16:41 on 26 Oct 2004

Re: inflating columns to objects
Drew Taylor 17:40 on 26 Oct 2004

Re: inflating columns to objects
Dave Howorth 13:24 on 27 Oct 2004

Re: inflating columns to objects
Drew Taylor 14:13 on 27 Oct 2004

Re: inflating columns to objects
Dave Howorth 14:33 on 27 Oct 2004

Re: inflating columns to objects
Drew Taylor 14:37 on 27 Oct 2004

Re: inflating columns to objects
Dave Howorth 16:17 on 27 Oct 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52