Mailing List Archive

$biz->add_contributor question
Hello Fellow Bricoleurs,

Wondering if you have any insight on the following:

my @p = Bric::Biz::Person->list( { id => '1100' } );

Returns Bric::Biz::Person object like so:

$VAR1 = bless( {
'mname' => '',
'fname' => 'First',
'lname' => 'Last,
'suffix' => '',
'_active' => '1',
'_dirty' => undef,
'grp_ids' => [
'1',
'39'
],
'id' => 1100,
'prefix' => ''
}, 'Bric::Biz::Person' );

However, the (undocumented) $biz->add_contributor method "requires Bric::Biz::Asset::Business->add_contributor's first argument to be a Bric::Util::Grp::Parts::Member::Contrib if it's an object (it could also be an ID)" (See changes for VERSION 1.8.11 (2006-06-19).

So it seems that I'm not able to pass a Bric::Biz::Person object to $biz->add_contributor and instead I must pass a Bric::Util::Grp::Parts::Member::Contrib object.

However, to find the Bric::Util::Grp::Parts::Member::Contrib object that I want, I can't use the ID of a Bric::Biz::Person object. This is where things get confusing, it seems to require the ID from the 'member' table that relates to the person.id via the person_member table.

Thus, the question I have is: How the heck do I lookup this zany "member id" from the Bric::Biz::Person object ?

For the object shown above, to get the right Bric::Util::Grp::Parts::Member::Contrib object, I need to use the following:

my $contrib = Bric::Util::Grp::Parts::Member::Contrib->lookup( { id => '3194' } );

Which results in:

$VAR1 = bless( {
'object_package' => 'Bric::Biz::Person',
'obj_id' => '1100',
'grp' => bless( {
'name' => 'Writers',
'secret' => '1',
'description' => '',
'permanent' => '0',
'_active' => '1',
'_dirty' => undef,
'grp_ids' => [
'35'
],
'id' => 39,
'class_id' => '9'
}, 'Bric::Util::Grp::Person' ),
'_active' => '1',
'_object_class_id' => '1',
'_dirty' => undef,
'id' => '3194',
'grp_id' => '39'
}, 'Bric::Util::Grp::Parts::Member::Contrib' );

Unfortunately, it seems like there's no option to pass an obj_id to Bric::Util::Grp::Parts::Member::Contrib->lookup -- thus, I don't see how I can lookup one of these objects using the information available from Bric::Biz::Person.

Am I missing something here? The documentation is a bit light in these corners of Bricolage...

Any thoughts appreciated.

Phillip.



--
Phillip Smith // Simplifier of Technology // COMMUNITY BANDWIDTH
www.communitybandwidth.ca // www.phillipadsmith.com
Re: $biz->add_contributor question [ In reply to ]
On 2010-07-20, at 8:09 PM, Phillip Smith wrote:

> Hello Fellow Bricoleurs,
>
> Wondering if you have any insight on the following:
>
> my @p = Bric::Biz::Person->list( { id => '1100' } );
>
> Returns Bric::Biz::Person object like so:
>
> $VAR1 = bless( {
> 'mname' => '',
> 'fname' => 'First',
> 'lname' => 'Last,
> 'suffix' => '',
> '_active' => '1',
> '_dirty' => undef,
> 'grp_ids' => [
> '1',
> '39'
> ],
> 'id' => 1100,
> 'prefix' => ''
> }, 'Bric::Biz::Person' );
>
> However, the (undocumented) $biz->add_contributor method "requires Bric::Biz::Asset::Business->add_contributor's first argument to be a Bric::Util::Grp::Parts::Member::Contrib if it's an object (it could also be an ID)" (See changes for VERSION 1.8.11 (2006-06-19).
>
> So it seems that I'm not able to pass a Bric::Biz::Person object to $biz->add_contributor and instead I must pass a Bric::Util::Grp::Parts::Member::Contrib object.
>
> However, to find the Bric::Util::Grp::Parts::Member::Contrib object that I want, I can't use the ID of a Bric::Biz::Person object. This is where things get confusing, it seems to require the ID from the 'member' table that relates to the person.id via the person_member table.
>
> Thus, the question I have is: How the heck do I lookup this zany "member id" from the Bric::Biz::Person object ?
>
> For the object shown above, to get the right Bric::Util::Grp::Parts::Member::Contrib object, I need to use the following:
>
> my $contrib = Bric::Util::Grp::Parts::Member::Contrib->lookup( { id => '3194' } );
>
> Which results in:
>
> $VAR1 = bless( {
> 'object_package' => 'Bric::Biz::Person',
> 'obj_id' => '1100',
> 'grp' => bless( {
> 'name' => 'Writers',
> 'secret' => '1',
> 'description' => '',
> 'permanent' => '0',
> '_active' => '1',
> '_dirty' => undef,
> 'grp_ids' => [
> '35'
> ],
> 'id' => 39,
> 'class_id' => '9'
> }, 'Bric::Util::Grp::Person' ),
> '_active' => '1',
> '_object_class_id' => '1',
> '_dirty' => undef,
> 'id' => '3194',
> 'grp_id' => '39'
> }, 'Bric::Util::Grp::Parts::Member::Contrib' );
>
> Unfortunately, it seems like there's no option to pass an obj_id to Bric::Util::Grp::Parts::Member::Contrib->lookup -- thus, I don't see how I can lookup one of these objects using the information available from Bric::Biz::Person.
>
> Am I missing something here? The documentation is a bit light in these corners of Bricolage...

Curious... digging through Bric::Util::Grp::Parts::Member::Contrib I found:

elsif ($k eq 'person_id') {
push @wheres, any_where($v, "p.id = ?", \@args);

Thus, creating the object like so:

my @contribs = Bric::Util::Grp::Parts::Member::Contrib->list({ person_id => $person_object->get_id });

Returns the right object.

As far as I can tell, this isn't documented. Thus, I'm wondering that I'm just looking at it wrong... any thoughts appreciated.

Phillip.

--
Phillip Smith // Simplifier of Technology // COMMUNITY BANDWIDTH
www.communitybandwidth.ca // www.phillipadsmith.com
Re: $biz->add_contributor question [ In reply to ]
On Jul 20, 2010, at 5:09 PM, Phillip Smith wrote:

> Unfortunately, it seems like there's no option to pass an obj_id to Bric::Util::Grp::Parts::Member::Contrib->lookup -- thus, I don't see how I can lookup one of these objects using the information available from Bric::Biz::Person.
>
> Am I missing something here? The documentation is a bit light in these corners of Bricolage...

my ($m) = Bric::Util::Grp::Parts::Member::Contrib->list({
object => $person,
grp => $grp,
});

But what is it you're trying to do?

Best,

David
Re: $biz->add_contributor question [ In reply to ]
On 2010-07-28, at 7:55 PM, David E. Wheeler wrote:

> On Jul 20, 2010, at 5:09 PM, Phillip Smith wrote:
>
>> Unfortunately, it seems like there's no option to pass an obj_id to Bric::Util::Grp::Parts::Member::Contrib->lookup -- thus, I don't see how I can lookup one of these objects using the information available from Bric::Biz::Person.
>>
>> Am I missing something here? The documentation is a bit light in these corners of Bricolage...
>
> my ($m) = Bric::Util::Grp::Parts::Member::Contrib->list({
> object => $person,
> grp => $grp,
> });
>
> But what is it you're trying to do?

I wrote a script to create a "contributor" story for each contributor in the system (will post on Github shortly). These contributor pages list all of the stories that have that contributor as an association. Thus, when I create the contributor story, I want to associate the contributor object with it, so I can then lookup stories based on that contributor. However, it proved quite tricky to get the contributor object... in the end, this was the solution that worked for me: http://www.gossamer-threads.com/lists/bricolage/users/39045#39045

--
Phillip Smith // Simplifier of Technology // COMMUNITY BANDWIDTH
www.communitybandwidth.ca // www.phillipadsmith.com