Solved the problem

[prev] [thread] [next] [Date index for 2005/02/05]

From: karjala_lists
Subject: Solved the problem
Date: 02:50 on 05 Feb 2005
I solved the problem.

I used "sub" directly (without 'has_a').

Did the following:

package Music::Artist;
use base [...];
sub homepage {
   ($obj, $value) = @_;
   if (defined $value) { Remote::Table->search(artist => 
$obj)->first->homepage($value); }
   else { return Remote::Table->search(artist => $obj)->first->homepage; }
}

and that does both accessing and setting.

Sorry for bothering the list,
- karjala



karjala_lists@xxxxxxx.xxx wrote:

> I want, for example, the "homepage" (which is non-existant in the main 
> database) method of Music::Artist to do a search in some other, remote 
> database and return me the result.
> Also when storing to the "homepage" field by writing 
> $artist->homepage($url), I would like Class::DBI to store $url in that 
> other, remote database.
>
> I looked in the manual but got no information from it that could lead me.
>
> Should my program look something like this?
>
> ====================
> package Music::Artist;
> use base [...]
> __PACKAGE__->has_a(homepage => 'Object::Name',
>    inflate => sub { return Remote::Table->search( artist => shift 
> )->first->homepage }
>    deflate => sub { Remote::Table->search ( artist => shift 
> )->first->homepage(shift) }
> ====================
>
> What I wrote above is quite different than the Time::Piece example 
> given in the Class::DBI manual, because:
> 1) The Class::DBI documentation example implies that the "homepage" 
> field exists in the local database (whereas in my case it doesn't)
> 2) "shift" inside the subs I define would return the value inside the 
> "homepage" field of the local Artists table (whereas in my case I want 
> it to return the value inside the primary key of the current record of 
> the local Artists table)
>
> How do you think I should go about doing this?
>
> Thank you,
> - karjala
>
>
>


Solved the problem
karjala_lists 02:50 on 05 Feb 2005

Generated at 21:37 on 09 Feb 2005 by mariachi v0.52