Re: [CDBI] Adding metadata to objects

[prev] [thread] [next] [Date index for 2005/09/27]

From: Bill Moseley
Subject: Re: [CDBI] Adding metadata to objects
Date: 20:42 on 27 Sep 2005
On Tue, Sep 27, 2005 at 04:17:12PM -0400, Kingsley Kerce wrote:
> Bill Moseley writes:
>  > Does CDBI provide a way to add meta data to object instances?
>  > 
>  > I want to generate a list of CDs, say limited to a given genre.  So
> 
> Bill -- Is genre a column in the CD and track tables?  If yes then
> just refer to item.genre (the CD's genre) in your template, discarding
> tracks whose genre doesn't match.

The Music example doesn't exactly fit my real database.  I was just
using it as an example.  I have a number of parameters that I need to
pass, and I can't test them based on existing columns.

The question is more about how to add metadata to an instance.

The real situation is this:

__PACKAGE__->set_sql('workshop_summary', <<SQL);
    SELECT id, name, short_description, scheduled_message, no_scheduled_message
    FROM workshop
    WHERE id IN (
        SELECT DISTINCT workshop FROM class
        WHERE
            register_cutoff_time >= now()
            AND review_mode IS NOT TRUE
            AND workshop_group = 1
    UNION
        SELECT id FROM workshop
        WHERE
            start_display_time IS NOT NULL
            AND start_display_time < now()
            AND (stop_display_time IS NULL or stop_display_time >= now())
            AND review_mode IS NOT TRUE
            AND workshop_group = 1
    )
    ORDER by name
SQL

Where the time "now()", review_mode, workshop_group (and a few others)
are set at run-time.  Then those same parameters used above need to be
passed in another method that fetches specific classes for each
workshop id returned above:

__PACKAGE__->set_sql('scheduled_classes', <<SQL);
    SELECT id, class_time, location
    FROM class
    WHERE 
        workshop = ?
        AND register_cutoff_time >= now()
        AND review_mode IS NOT TRUE
        AND workshop_group = 1
    ORDER by class_time
SQL

So, currently I'm storing all the parameters in the catalyst stash and
passing those parameters when calling "scheduled_classes".  But it
would be nice to store the parameters as metadata in each instance
form the first select making them available for the second select.

In other words:

    item.scheduled_classes

would then pass in the parameters used to select the "item" in the
first place.

Make sense?


        -- 
        Bill Moseley
moseley@xxxx.xxx


_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

[CDBI] Adding metadata to objects
Bill Moseley 19:42 on 27 Sep 2005

Re: [CDBI] Adding metadata to objects
Kingsley Kerce 20:17 on 27 Sep 2005

Re: [CDBI] Adding metadata to objects
Bill Moseley 20:42 on 27 Sep 2005

Re: [CDBI] Adding metadata to objects
Wayne Walker 21:10 on 27 Sep 2005

Re: [CDBI] Adding metadata to objects
Peter Speltz 21:46 on 27 Sep 2005

Re: [CDBI] Adding metadata to objects
Kingsley Kerce 01:00 on 28 Sep 2005

Generated at 10:29 on 10 Oct 2005 by mariachi v0.52