Re: Associate Config::Scoped info with a CDBI row

[prev] [thread] [next] [Date index for 2005/04/15]

From: merlyn (Randal L. Schwartz)
Subject: Re: Associate Config::Scoped info with a CDBI row
Date: 20:32 on 15 Apr 2005
>>>>> "Kingsley" == Kingsley Kerce <kingsley@xxxxxxxxxxxxxxxx.xxx> writes:

Kingsley> Merlyn -- If you would like to associate info with a CDBI row (as
Kingsley> stated in your Subject line), why not adjust your database schema and
Kingsley> store the info in the database?

I can't change the database schema.  I'm wrapping an existing design.

Kingsley> Randal L. Schwartz writes:
>> I tell you, it's very very nice to get something you can access
>> from both Perl and Template Toolkit to once and only once define
>> meta information about your columns for various views.

Kingsley> TMTOWTDI, but for MVC view-based info, I would store the
Kingsley> info as close as possible to the view code, i.e., put the
Kingsley> info in your TT template files.  If the info is referenced
Kingsley> in multiple template files, use INCLUDE.

This information bridges view and model.  I think about it at the
model level, but it's needed by the view.  And in this case, the view
is both some Perl code and some TT code, so both Perl and TT need to
see it.  Thus, I'd be stuck reinventing some sort of hash syntax, plus
I needed overriding defaults, and Config::Scoped works great for that.


    view = textfield
    textfield_width = 8 # this is the default
    get = get
    set = set

    first_name { } # creates { view => 'textfield', textfield_width = '8' }
    last_name { textfield_width = 20 } # overrides width
    comment { view = textarea } # now creates view => 'textarea'
    date { get = get_date set = set_date } # override getter/setter

It's working better than any combination I've used before, and I've
tried a lot.

        -- 
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@xxxxxxxxxx.xxx> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Associate Config::Scoped info with a CDBI row
merlyn (Randal L. Schwartz) 16:38 on 15 Apr 2005

Re: Associate Config::Scoped info with a CDBI row
merlyn (Randal L. Schwartz) 17:15 on 15 Apr 2005

Re: Associate Config::Scoped info with a CDBI row
Kingsley Kerce 17:21 on 15 Apr 2005

Re: Associate Config::Scoped info with a CDBI row
merlyn (Randal L. Schwartz) 20:32 on 15 Apr 2005

Re: Associate Config::Scoped info with a CDBI row
William Ross 19:03 on 15 Apr 2005

Re: Associate Config::Scoped info with a CDBI row
merlyn (Randal L. Schwartz) 20:34 on 15 Apr 2005

Generated at 12:49 on 16 Apr 2005 by mariachi v0.52