[Maypole] Re: Getting a New CDBI object without creating one in db?

From: Peter Speltz (peterspeltz at yahoo.com)
Date: Tue Oct 19 2004 - 00:50:20 BST


--- Perrin Harkins <perrin at elem.com> wrote:

> On Sat, 2004-10-16 at 01:43, Peter Speltz wrote:
> > In my particular situation, I use Template Toolkit and i need/want (and
> now
> > have) an instance of an obj in my "new" template so that i can populated
> drop
> > down lists of choices and default values. Ex: In the customer/new page,
> i
> > would use "cstmr_obj.types" and cstmr_obj.default_xxx to populate a drop
> down
> > list and an input box. These methods would definitely be class methods.

> I'm confused then. What do you need an object for? Just call the class
> method.

I'm trying to access the method in a TT template. Does that answer your
question? In a TT template you need an obj ref to call any methods of a class
, whether they are class methods or not. I tried [% Customer::types%] and it
gave a parse error so i'm deducting this assertion from that experiment (and
probably others).

Kind people have informed me of the Template::Plugin module and that is
acceptable. However if i know ahead of time I will need class methods of an
object in a template , I sometimes just bless a template arg into the class i
need.

As an aside, this question started with Maypole , where every default model
method sends the template an object(s) of the appropriate type unless you're
creating a new object of that type. Then you have no object.

> > Is there a better place to put methods like these?

> Class methods are generally the best place to put something related to a
> specific type of object but not a specific instance of an object.
>

First, thanks for sharing your wisdom as you do again and again on the mailing
lists. You've helped me out numerous times. In this instance you inspired me to
revisit my understanding of class methods and instance methods in perl. Can you
call a class method from a template?

thanks

> - Perrin
>
>

=====
pjs

                
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

_______________________________________________
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