Re: Access to has_a data from Template?

[prev] [thread] [next] [Date index for 2004/09/16]

From: Jesse Sheidlower
Subject: Re: Access to has_a data from Template?
Date: 17:39 on 16 Sep 2004
On Thu, Sep 16, 2004 at 06:30:16PM +0100, Tony Bowden wrote:
> On Thu, Sep 16, 2004 at 07:28:52AM -0400, Jesse Sheidlower wrote:
> > Suppose I'm looking at a "book", each book being a
> > MyLibrary::Book, and each "book" has_a "format"
> > (hardcover, paperback, etc.). If I do:
> >   [% USE book = Class("MyLibrary::Book") %]
> > I still can't seem to get to at the format data:
> >   FOREACH format = book.format
> > bombs out with
> >   undef error - Can't fetch data as class method at
> 
> Well, of course it will. You're asking for the format of ALL books, which
> makes no sense. You presumably want the format of a particular book,
> which should be getting passed into the template somehow...

No, I want to access a "format" object, to call things on it.

The FOREACH was just an example, but in reality, I'd want to 
retrieve_all from format, so I can construct a select list
(or whatever) from the results.

If I do have an object representing a particular book, it will
be passed into the template (as, let's say, "book"), and
_then_ I can ask for the format so I can do something like

  [% CGI.popup_menu({ name => "format",
        values => ## SOMETHING
        labels => ## SOMETHING
        default => book.format
   }) %]

But here I'm asking about the situation of being in the "book" class
and wanting to get info from its has_a class "format" to get to the
values and labels in the above.

I must be expressing myself very unclearly, because it can't be
as hard to do this as I'm making it out to be.

Thanks.

Jesse Sheidlower

(message missing)

Access to has_a data from Template?
Jesse Sheidlower 11:28 on 16 Sep 2004

Re: Access to has_a data from Template?
Tony Bowden 17:30 on 16 Sep 2004

Re: Access to has_a data from Template?
Jesse Sheidlower 17:39 on 16 Sep 2004

Re: Access to has_a data from Template?
Tony Bowden 19:02 on 16 Sep 2004

Re: Access to has_a data from Template?
Jesse Sheidlower 19:19 on 16 Sep 2004

Re: Access to has_a data from Template?
Tony Bowden 22:23 on 16 Sep 2004

Re: Access to has_a data from Template?
Charles Bailey 23:31 on 16 Sep 2004

Re: Access to has_a data from Template?
Richard Clamp 19:28 on 22 Sep 2004

Re: Access to has_a data from Template?
Jesse Sheidlower 18:09 on 16 Sep 2004

Re: Access to has_a data from Template?
Edward J. Sabol 19:01 on 16 Sep 2004

Re: Access to has_a data from Template?
Clayton L. Scott 21:25 on 16 Sep 2004

Re: Access to has_a data from Template?
Jesse Sheidlower 13:38 on 17 Sep 2004

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