Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Bricolage: users

Unfamiliar Error

 

 

Bricolage users RSS feed   Index | Next | Previous | View Threaded


smith_t at denison

Jul 25, 2008, 12:25 PM

Post #1 of 8 (336 views)
Permalink
Unfamiliar Error

Hey Guys,

So for the first time I have started getting a new error while
templating in Bricolage and I hoped you could help me out with it. I
am trying to take a UID and if it does not match any UIDs currently
stored within the 'uid' field of 'event_uid' container elements then
to create a new container element and store my uid and related story
there as such. This is my current code:

#Store the returned UID
my $uidstory = Bric::Biz::Asset::Business::Story->list({uuid =>
'595FC2AC-58B9-11DD-800B-39D208E6C7E9'});
my $match = 0;
foreach my $euid ($uidstory->get_elements()){
#Check if UID is already stored
if ($euid->has_name('event_uid')) {
if($uid == $euid->get_data('uid')){$match++;}
}
}
if($match == 0){
#Store new UID and relate current story
my $container = Bric::Biz::Element::Container->list({key_name =>
'event_uid'});
my $curuidstory = $uidstory->add_container($container);
my $uidfield = $curuidstory->get_field('uid');
$uidfield->set_value($uid);
$curuidstory->set_related_story($story);
}

The new error that I keep getting is:
Can't call method "get_elements" on unblessed reference at
/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event.mc line
87, <GEN2441> line 1716.

My question is what is an unblessed reference? I am getting the above
error on this line from above: "foreach my $euid
($uidstory->get_elements()){".

Any help with this would be greatly appreciated.

-Trevor


chris.schults at pccsea

Jul 25, 2008, 12:51 PM

Post #2 of 8 (330 views)
Permalink
RE: Unfamiliar Error [In reply to]

> The new error that I keep getting is:
> Can't call method "get_elements" on unblessed reference at
> /usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event.mc line
> 87, <GEN2441> line 1716.
>
> My question is what is an unblessed reference? I am getting the above
> error on this line from above: "foreach my $euid
> ($uidstory->get_elements()){".

Trevor, I run into this all the time and embarrassingly don't exactly
know the reason behind it. However, I believe it is because Story->list
returns an array or list. I get around this by putting the variable
declaration in parenthesis like so:

my ($uidstory) = Bric::Biz::Asset::Business::Story->list({uuid =>
'595FC2AC-58B9-11DD-800B-39D208E6C7E9'});

Perhaps the more experienced can enlighten us.

Chris

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.


smith_t at denison

Jul 25, 2008, 12:56 PM

Post #3 of 8 (332 views)
Permalink
Re: Unfamiliar Error [In reply to]

weird, yeah i get the same error from this line:
my $container = Bric::Biz::Element::Container->list({object =>
$uidstory, key_name => 'event_uid'});

unless i do this:
my ($container) = Bric::Biz::Element::Container->list({object =>
$uidstory, key_name => 'event_uid'});

On Fri, Jul 25, 2008 at 3:51 PM, Schults, Chris
<chris.schults[at]pccsea.com> wrote:
>> The new error that I keep getting is:
>> Can't call method "get_elements" on unblessed reference at
>> /usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event.mc line
>> 87, <GEN2441> line 1716.
>>
>> My question is what is an unblessed reference? I am getting the above
>> error on this line from above: "foreach my $euid
>> ($uidstory->get_elements()){".
>
> Trevor, I run into this all the time and embarrassingly don't exactly
> know the reason behind it. However, I believe it is because Story->list
> returns an array or list. I get around this by putting the variable
> declaration in parenthesis like so:
>
> my ($uidstory) = Bric::Biz::Asset::Business::Story->list({uuid =>
> '595FC2AC-58B9-11DD-800B-39D208E6C7E9'});
>
> Perhaps the more experienced can enlighten us.
>
> Chris
>
> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.
>


david at kineticode

Jul 25, 2008, 3:07 PM

Post #4 of 8 (330 views)
Permalink
Re: Unfamiliar Error [In reply to]

On Jul 25, 2008, at 12:25, Trevor Smith wrote:

> my $uidstory = Bric::Biz::Asset::Business::Story->list({uuid =>
> '595FC2AC-58B9-11DD-800B-39D208E6C7E9'});

Use lookup() instead of list() if you're just looking up one object.

Best,

David


lannings at who

Jul 27, 2008, 2:07 PM

Post #5 of 8 (313 views)
Permalink
Re: Unfamiliar Error [In reply to]

In Bricolage, Whatever->list ordinarily returns
an array reference (which is a scalar) in scalar context,
or a list in list context. In

my $foo = ...

it is a scalar context, so it will be an aref,
and you'd access it like

$foo->[0]

or whatever. In

my ($foo) = ...

or

my ($foo, $bar) = ...

or

my ($foo, undef, undef, $quux) = ...

or

my @foo = ...

or even

my %foo = ...

it is a list context. (Assigning to a hash (%foo)
would be stupid for Whatever->list, however.)
In the case of

my ($foo) = ...

only the first item of the list will be put in $foo,
while any more items will be discarded. $foo will generally
be an object (instance) of Whatever class. If you use
Whatever->list_ids in most classes, it will return
a list of ID numbers instead of objects.

On Fri, 25 Jul 2008, Trevor Smith wrote:
> weird, yeah i get the same error from this line:
> my $container = Bric::Biz::Element::Container->list({object =>
> $uidstory, key_name => 'event_uid'});
>
> unless i do this:
> my ($container) = Bric::Biz::Element::Container->list({object =>
> $uidstory, key_name => 'event_uid'});
>
> On Fri, Jul 25, 2008 at 3:51 PM, Schults, Chris
> <chris.schults[at]pccsea.com> wrote:
>>> The new error that I keep getting is:
>>> Can't call method "get_elements" on unblessed reference at
>>> /usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event.mc line
>>> 87, <GEN2441> line 1716.
>>>
>>> My question is what is an unblessed reference? I am getting the above
>>> error on this line from above: "foreach my $euid
>>> ($uidstory->get_elements()){".
>>
>> Trevor, I run into this all the time and embarrassingly don't exactly
>> know the reason behind it. However, I believe it is because Story->list
>> returns an array or list. I get around this by putting the variable
>> declaration in parenthesis like so:
>>
>> my ($uidstory) = Bric::Biz::Asset::Business::Story->list({uuid =>
>> '595FC2AC-58B9-11DD-800B-39D208E6C7E9'});
>>
>> Perhaps the more experienced can enlighten us.
>>
>> Chris


david at kineticode

Jul 27, 2008, 5:22 PM

Post #6 of 8 (312 views)
Permalink
Re: Unfamiliar Error [In reply to]

On Jul 27, 2008, at 14:07, Scott Lanning wrote:

> In the case of
>
> my ($foo) = ...
>
> only the first item of the list will be put in $foo,
> while any more items will be discarded.

Actually, I think that you get the *last* thing, though I'm not sure.

Best,

David


lannings at who

Jul 28, 2008, 12:01 AM

Post #7 of 8 (309 views)
Permalink
Re: Unfamiliar Error [In reply to]

On Sun, 27 Jul 2008, David E. Wheeler wrote:
> On Jul 27, 2008, at 14:07, Scott Lanning wrote:
>> my ($foo) = ...
>>
>> only the first item of the list will be put in $foo,
>> while any more items will be discarded.
>
> Actually, I think that you get the *last* thing, though I'm not sure.

$ perl -le'@_=2..7;($_)=@_;print'
2


david at kineticode

Jul 29, 2008, 11:17 AM

Post #8 of 8 (297 views)
Permalink
Re: Unfamiliar Error [In reply to]

On Jul 28, 2008, at 00:01, Scott Lanning wrote:

>> Actually, I think that you get the *last* thing, though I'm not sure.
>
> $ perl -le'@_=2..7;($_)=@_;print'

You and your empiricism! ;-)

Best,

David

Bricolage users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.