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

Mailing List Archive: Bricolage: users

API Access of Updated Pages

 

 

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


rolfm at denison

Jul 19, 2008, 12:11 AM

Post #1 of 25 (956 views)
Permalink
API Access of Updated Pages

We've updated some stories via the API and we've noticed that we can
no longer access the elements or the fields in those stories via API
methods in templates. Calls like get_primary_category still work, and
even get_elements. But as soon as we try get_value, get_container, or
get_data, all we are returned is "undefined", despite the fact that
the containers are there and the data is quite clearly in the fields.

Our update activity consisted of adding a field to the stories and
removing another. We did not touch the fields we are currently trying
to access. I can tell no noticeable difference between the story and
story_instance fields of good and bad pages. Furthermore, story_field
shows the correct number of instances.

The problem goes away if a person checks out a story through the
interface and checks it back in. At that point the story is able to
be accessed again using the API call in templates. However, checking
a story in and out *using* the API does not seem to have the same
healing effect.

Any suggestions for fixing this programatically? I'm not really
looking forward to manually checking these stories out and in.

Thanks,

Matt


rolfm at denison

Jul 19, 2008, 12:21 AM

Post #2 of 25 (931 views)
Permalink
Re: API Access of Updated Pages [In reply to]

Furthermore, we have some material that was SOAPED in which shows the
same behavior.

-Matt

On Jul 19, 2008, at 3:11 AM, Matt Rolf wrote:

> We've updated some stories via the API and we've noticed that we can
> no longer access the elements or the fields in those stories via API
> methods in templates. Calls like get_primary_category still work,
> and even get_elements. But as soon as we try get_value,
> get_container, or get_data, all we are returned is "undefined",
> despite the fact that the containers are there and the data is quite
> clearly in the fields.
>
> Our update activity consisted of adding a field to the stories and
> removing another. We did not touch the fields we are currently
> trying to access. I can tell no noticeable difference between the
> story and story_instance fields of good and bad pages. Furthermore,
> story_field shows the correct number of instances.
>
> The problem goes away if a person checks out a story through the
> interface and checks it back in. At that point the story is able to
> be accessed again using the API call in templates. However,
> checking a story in and out *using* the API does not seem to have
> the same healing effect.
>
> Any suggestions for fixing this programatically? I'm not really
> looking forward to manually checking these stories out and in.
>
> Thanks,
>
> Matt


rolfm at denison

Jul 21, 2008, 8:31 AM

Post #3 of 25 (919 views)
Permalink
Re: API Access of Updated Pages [In reply to]

Ok, so media is looking like a tougher nut to crack - check out/check
in does not solve the problem..

Here is our template code. It is based on the imagemagick template
that was posted to this list a while ago.

my $thumbnailElementType = Bric::Biz::ElementType->lookup({ key_name
=> 'thumbnail_photo' });
my $thumbnailElementTypeID = $thumbnailElementType->get_id;
my %thumbnailInitialState = ({
priority => $story->get_priority,
user__id => ($story->get_user__id || 1045),
title => $fullSizeMedia->get_title . " (Thumbnail)",
category__id => $fullSizeMedia->get_category__id,
site_id => $story->get_site_id,
source__id => $fullSizeMedia->get_source__id,
workflow_id => $fullSizeMedia->get_workflow_id,
cover_date => $fullSizeMedia->get_cover_date,
element_type => $thumbnailElementType,
media_type_id => $fullSizeMedia->get_media_type->get_id
});

....
$newthumbnail = Bric::Biz::Asset::Business::Media->new(\
%thumbnailInitialState);


The error we get is

Cannot create an asset without an element type or alias ID

And it points to the last line up there.

Our code appears to work with images that are uploaded through the
interface, but not ones that are soaped in.

We are also getting hashes for the %thumbnailInitialState and
%thumbnailElementType

Any help is much appreciated, as we are in a bit of a bind.

-Matt


rolfm at denison

Jul 21, 2008, 10:26 AM

Post #4 of 25 (919 views)
Permalink
Re: API Access of Updated Pages [In reply to]

All right - so as far as the stories go, we've determined that what
fixes them is the actual opening of the story in the interface. We
don't have to check it back in and shelve it, just pulling it up fixes
the story.

We've been looking at story_prof.mc for some sort of clue as to what
exactly is getting triggered when this happens, and why our other
stories don't have it, but we can't figure it out. We realized that
in the current instance, we weren't passing versions for the checkout/
checkin, but that doesn't see to affect things whether or not the
version shows up in the log file for a particular story. Any
suggestions?

Thanks,

Matt


david at kineticode

Jul 21, 2008, 10:37 AM

Post #5 of 25 (918 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 19, 2008, at 00:11, Matt Rolf wrote:

> We've updated some stories via the API and we've noticed that we can
> no longer access the elements or the fields in those stories via API
> methods in templates. Calls like get_primary_category still work,
> and even get_elements. But as soon as we try get_value,
> get_container, or get_data, all we are returned is "undefined",
> despite the fact that the containers are there and the data is quite
> clearly in the fields.

Can you post the code that does this? Something is likely left out.

Best,

David


david at kineticode

Jul 21, 2008, 10:38 AM

Post #6 of 25 (919 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 19, 2008, at 00:21, Matt Rolf wrote:

> Furthermore, we have some material that was SOAPED in which shows
> the same behavior.

That sounds like a SOAP bug.

Best,

David


david at kineticode

Jul 21, 2008, 10:41 AM

Post #7 of 25 (920 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 21, 2008, at 08:31, Matt Rolf wrote:

> The error we get is
>
> Cannot create an asset without an element type or alias ID
>
> And it points to the last line up there.
>
> Our code appears to work with images that are uploaded through the
> interface, but not ones that are soaped in.
>
> We are also getting hashes for the %thumbnailInitialState and
> %thumbnailElementType
>
> Any help is much appreciated, as we are in a bit of a bind.

Can you send the full stack trace from the logs?

Thanks,

David


rolfm at denison

Jul 21, 2008, 1:19 PM

Post #8 of 25 (917 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 21, 2008, at 1:41 PM, David E. Wheeler wrote:

> On Jul 21, 2008, at 08:31, Matt Rolf wrote:
>
>> The error we get is
>>
>> Cannot create an asset without an element type or alias ID
>>
>> And it points to the last line up there.
>>
>> Our code appears to work with images that are uploaded through the
>> interface, but not ones that are soaped in.
>>
>> We are also getting hashes for the %thumbnailInitialState and
>> %thumbnailElementType
>>
>> Any help is much appreciated, as we are in a bit of a bind.
>
> Can you send the full stack trace from the logs?


Ok, we have two errors - one from the stories, and one from the media.

Here is the code from the stories error, Lines 17-28.

#we're using the story_list utility template to grab the most recent
stories from all categories under the current one.
my @recentstories = $m->comp( 'story_list.mc', story_types =>
[qw(news_release)], all_subcats => 1, max => 20, site_ids => [$story-
>get_site_id]);
my $count = 0;
foreach my $rel (@recentstories) {

$count++;
if($count <= 12){
#we will check to see if the user entered a Teaser; if not, we'll use
the first 230 characters of the story for the teaser on the index page
my $text;

if($rel->get_data('teaser') eq ''){
$text = $rel->get_container('rich_paragraph')->get_data('paragraph');

And here is the stack trace:


<!-- DEBUGGING INFORMATION.

Error: Can&#39;t call method &quot;get_data&quot; on an undefined
value at /usr/local/bricolage/data/burn/comp/oc_1/news_list_print.mc
line 28, &lt;GEN4247&gt; line 502.


Fault Class: HTML::Mason::Exception
Description: generic base class for all Mason exceptions
Timestamp: 2008-07-21 13:47:45.000000
Package: HTML::Mason::Exceptions
Filename: /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
Exceptions.pm
Line: 129

STACK:

Can't call method "get_data" on an undefined value at /usr/local/
bricolage/data/burn/comp/oc_1/news_list_print.mc line 28, <GEN4247>
line 502.

Stack:
[/usr/local/bricolage/data/burn/comp/oc_1/news_list_print.mc:28]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
[/usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm:557]
[/usr/local/bricolage/data/burn/comp/oc_1/autohandler:120]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]

END DEBUGGING INFORMATION -->


rolfm at denison

Jul 21, 2008, 1:19 PM

Post #9 of 25 (914 views)
Permalink
Re: API Access of Updated Pages [In reply to]

Here is the code from one of our media problems:

$m->comp( 'image_magick.mc', element => $e );

image_magick.mc line 89
Lines 46-90

#if no thumbnail version is present, create one
if (!$thumbnailElement) {
if ($imageIsgood){
#$m->out('<br /><br />NO THUMBNAIL ELEMENT FOUND. WILL TRY TO MAKE
ONE.');
#set all the details for the media document that will contain the
thumbnail photo
my $thumbnailElementType = Bric::Biz::ElementType-
>lookup({ key_name => 'thumbnail_photo' });
my $thumbnailElementTypeID = $thumbnailElementType->get_id;
my %thumbnailInitialState = ({
priority => $story->get_priority,
user__id => ($story->get_user__id || 1045),
title => $fullSizeMedia->get_title . " (Thumbnail)",
category__id => $fullSizeMedia->get_category__id,
site_id => $story->get_site_id,
source__id => $fullSizeMedia->get_source__id,
workflow_id => $fullSizeMedia->get_workflow_id,
cover_date => $fullSizeMedia->get_cover_date,
element_type => $thumbnailElementType,
#element_type_id => $thumbnailElementTypeID,
media_type_id => $fullSizeMedia->get_media_type->get_id
});

$thumbnailFileName = $fullSizeMedia->get_file_name;
$thumbnailURI = $fullSizeMedia->get_primary_uri;
$thumbnailFileName =~ s/....$/_tb.jpg/;
$thumbnailURI =~ s/....$/_tb.jpg/;
my $thumbnailTmpFile = "/tmp/$thumbnailFileName";

#check if there is already a thumbnail image in the Bricolage
library.
#If there is, open that media document. Otherwise create a new one.
my @existingthumbnail = Bric::Biz::Asset::Business::Media->list({
#uri => $thumbnailURI,
active => 1
});

foreach my $candidate (@existingthumbnail) {
if ($candidate->get_uri eq $thumbnailURI) {
$newthumbnail = $candidate;
$newthumbnail->checkout( {'user__id' => $story->get_user__id() ||
1045 });
$weDontNeedANewthumbnail = 1;
last;
}
}

if($weDontNeedANewthumbnail == 0){
$newthumbnail = Bric::Biz::Asset::Business::Media->new(\
%thumbnailInitialState);

Here is the stacktrace.
<!-- DEBUGGING INFORMATION.

Error: Cannot create an asset without an element type or alias ID

Fault Class: Bric::Util::Fault::Exception::DP
Description: Data Processing Exception
Timestamp: 2008-07-21 14:51:43.000000
Package: Bric::Biz::Asset::Business
Filename: /usr/local/bricolage/lib/Bric/Biz/Asset/Business.pm
Line: 2321
Payload:

STACK:

Trace begun at /usr/local/bricolage/lib/Bric/Biz/Asset/Business.pm
line 2321
Bric
::Biz
::Asset
::Business
::_init('Bric::Biz::Asset::Business::Media=HASH(0x14a51ad4)',
'HASH(0x1123c1e4)') called at /usr/local/bricolage/lib/Bric/Biz/Asset/
Business.pm line 253
Bric::Biz::Asset::Business::new('Bric::Biz::Asset::Business::Media',
'HASH(0x1123c1e4)') called at /usr/local/bricolage/lib/Bric/Biz/Asset/
Business/Media.pm line 518
Bric
::Biz
::Asset::Business::Media::new('Bric::Biz::Asset::Business::Media',
'HASH(0x1123c1e4)') called at /usr/local/bricolage/data/burn/sandbox/
user_1029/oc_1/image_magick.mc line 89
Bric::Util::Burner::Commands::__ANON__('element',
'Bric::Biz::Element::Container=HASH(0x1224d8c0)') called at /usr/local/
lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm line 135
HTML
::Mason
::Component::run('HTML::Mason::Component::FileBased=HASH(0xb7808a4c)',
'element', 'Bric::Biz::Element::Container=HASH(0x1224d8c0)') called
at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 1256
eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
Request.pm line 1246
HTML::Mason::Request::comp(undef, undef, 'element',
'Bric::Biz::Element::Container=HASH(0x1224d8c0)') called at /usr/local/
bricolage/data/burn/comp/oc_1/press_release.mc line 60
Bric::Util::Burner::Commands::__ANON__ at /usr/local/lib/perl5/
site_perl/5.8.8/HTML/Mason/Component.pm line 135
HTML
::Mason
::Component::run('HTML::Mason::Component::FileBased=HASH(0x11230118)')
called at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm
line 1256
eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
Request.pm line 1246
HTML::Mason::Request::comp(undef, undef, undef) called at /usr/local/
lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 915
HTML
::Mason::Request::call_next('HTML::Mason::Request=HASH(0x1123bc74)')
called at /usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm line 557
Bric
::Util
::Burner
::Mason::chain_next('Bric::Util::Burner::Mason=HASH(0x1224d974)')
called at /usr/local/bricolage/data/burn/comp/oc_1/autohandler line 120
Bric::Util::Burner::Commands::__ANON__ at /usr/local/lib/perl5/
site_perl/5.8.8/HTML/Mason/Component.pm line 135
HTML
::Mason
::Component::run('HTML::Mason::Component::FileBased=HASH(0x12188418)')
called at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm
line 1251
eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
Request.pm line 1246
HTML::Mason::Request::comp(undef, undef, undef) called at /usr/local/
lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 460
eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
Request.pm line 460
eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
Request.pm line 412
HTML::Mason::Request::exec('HTML::Mason::Request=HASH(0x1123bc74)')
called at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Interp.pm
line 342
HTML::Mason::Interp::exec(undef, undef) called at /usr/local/bricolage/
lib/Bric/Util/Burner/Mason.pm line 268
eval {...} at /usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm line
268
Bric
::Util
::Burner
::Mason::burn_one('Bric::Util::Burner::Mason=HASH(0x1224d974)',
'Bric::Biz::Asset::Business::Story=HASH(0x1224cc84)',
'Bric::Biz::OutputChannel=HASH(0xb7812eb0)',
'Bric::Biz::Category=HASH(0x12197ac0)') called at /usr/local/bricolage/
lib/Bric/Util/Burner.pm line 1581
Bric::Util::Burner::burn_one('Bric::Util::Burner=HASH(0x1224b1d8)',
'Bric::Biz::Asset::Business::Story=HASH(0x1224cc84)',
'Bric::Biz::OutputChannel=HASH(0xb7812eb0)',
'Bric::Biz::Category=HASH(0x12197ac0)') called at /usr/local/bricolage/
lib/Bric/Util/Burner.pm line 967
eval {...} at /usr/local/bricolage/lib/Bric/Util/Burner.pm line 919
Bric::Util::Burner::preview('Bric::Util::Burner=HASH(0x1224b1d8)',
'Bric::Biz::Asset::Business::Story=HASH(0x1224cc84)', 'story', 1029,
undef) called at /usr/local/bricolage/lib/Bric/App/Callback/Publish.pm
line 117
Bric
::App
::Callback
::Publish::preview('Bric::App::Callback::Publish=HASH(0x1124996c)')
called at /usr/local/bricolage/comp/workflow/profile/preview/dhandler
line 36
HTML::Mason::Commands::__ANON__('checkout', 1, 'checkout', 1) called
at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm line 135
HTML
::Mason
::Component::run('HTML::Mason::Component::FileBased=HASH(0xad3a940)',
'checkout', 1, 'checkout', 1) called at /usr/local/lib/perl5/site_perl/
5.8.8/HTML/Mason/Request.pm line 1256
eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
Request.pm line 1246
HTML::Mason::Request::comp(undef, undef, undef, 'checkout', 1,
'checkout', 1) called at /usr/local/lib/perl5/site_perl/5.8.8/HTML/
Mason/Request.pm line 915
HTML
::Mason
::Request
::call_next('HTML::Mason::Request::ApacheHandler=HASH(0x12196fb0)',
'checkout', 1) called at /usr/local/bricolage/comp/autohandler line 7
HTML::Mason::Commands::__ANON__('checkout', 1) called at /usr/local/
lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm line 135
HTML
::Mason
::Component::run('HTML::Mason::Component::FileBased=HASH(0xa9675ec)',
'checkout', 1) called at /usr/local/lib/perl5/site_perl/5.8.8/HTML/
Mason/Request.pm line 1251
eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
Request.pm line 1246
HTML::Mason::Request::comp(undef, undef, undef, 'checkout', 1) called
at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 460
eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
Request.pm line 460
eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
Request.pm line 412
HTML
::Mason
::Request
::exec('HTML::Mason::Request::ApacheHandler=HASH(0x12196fb0)') called
at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/ApacheHandler.pm
line 168
HTML
::Mason
::Request
::ApacheHandler
::exec('HTML::Mason::Request::ApacheHandler=HASH(0x12196fb0)') called
at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/ApacheHandler.pm
line 826
HTML
::Mason
::ApacheHandler
::handle_request('HTML::Mason::ApacheHandler=HASH(0xa89a460)',
'Apache=SCALAR(0x1223c9b8)') called at /usr/local/bricolage/lib/Bric/
App/Handler.pm line 314
eval {...} at /usr/local/bricolage/lib/Bric/App/Handler.pm line 303
Bric::App::Handler::handler('Apache=SCALAR(0x1223c9b8)') called at /
dev/null line 0
eval {...} at /dev/null line 0

END DEBUGGING INFORMATION -->


bret at pectopah

Jul 21, 2008, 1:39 PM

Post #10 of 25 (916 views)
Permalink
Re: API Access of Updated Pages [In reply to]

Hi Matt.

Hey, this looks like it's based on one of ours!

Are you sure that your lookup for the thumbnail_photo element type is
succeeding?

There's a much more fully-featured version of this template now, if
you're interested. When I have a moment to breathe I'll put it up on
builidngbrics, but let me know if I should just post it here too.


Hope this helps,

Bret




On Mon, 2008-07-21 at 16:19 -0400, Matt Rolf wrote:
> Here is the code from one of our media problems:
>
> $m->comp( 'image_magick.mc', element => $e );
>
> image_magick.mc line 89
> Lines 46-90
>
> #if no thumbnail version is present, create one
> if (!$thumbnailElement) {
> if ($imageIsgood){
> #$m->out('<br /><br />NO THUMBNAIL ELEMENT FOUND. WILL TRY TO MAKE
> ONE.');
> #set all the details for the media document that will contain the
> thumbnail photo
> my $thumbnailElementType = Bric::Biz::ElementType-
> >lookup({ key_name => 'thumbnail_photo' });
> my $thumbnailElementTypeID = $thumbnailElementType->get_id;
> my %thumbnailInitialState = ({
> priority => $story->get_priority,
> user__id => ($story->get_user__id || 1045),
> title => $fullSizeMedia->get_title . " (Thumbnail)",
> category__id => $fullSizeMedia->get_category__id,
> site_id => $story->get_site_id,
> source__id => $fullSizeMedia->get_source__id,
> workflow_id => $fullSizeMedia->get_workflow_id,
> cover_date => $fullSizeMedia->get_cover_date,
> element_type => $thumbnailElementType,
> #element_type_id => $thumbnailElementTypeID,
> media_type_id => $fullSizeMedia->get_media_type->get_id
> });
>
> $thumbnailFileName = $fullSizeMedia->get_file_name;
> $thumbnailURI = $fullSizeMedia->get_primary_uri;
> $thumbnailFileName =~ s/....$/_tb.jpg/;
> $thumbnailURI =~ s/....$/_tb.jpg/;
> my $thumbnailTmpFile = "/tmp/$thumbnailFileName";
>
> #check if there is already a thumbnail image in the Bricolage
> library.
> #If there is, open that media document. Otherwise create a new one.
> my @existingthumbnail = Bric::Biz::Asset::Business::Media->list({
> #uri => $thumbnailURI,
> active => 1
> });
>
> foreach my $candidate (@existingthumbnail) {
> if ($candidate->get_uri eq $thumbnailURI) {
> $newthumbnail = $candidate;
> $newthumbnail->checkout( {'user__id' => $story->get_user__id() ||
> 1045 });
> $weDontNeedANewthumbnail = 1;
> last;
> }
> }
>
> if($weDontNeedANewthumbnail == 0){
> $newthumbnail = Bric::Biz::Asset::Business::Media->new(\
> %thumbnailInitialState);
>
> Here is the stacktrace.
> <!-- DEBUGGING INFORMATION.
>
> Error: Cannot create an asset without an element type or alias ID
>
> Fault Class: Bric::Util::Fault::Exception::DP
> Description: Data Processing Exception
> Timestamp: 2008-07-21 14:51:43.000000
> Package: Bric::Biz::Asset::Business
> Filename: /usr/local/bricolage/lib/Bric/Biz/Asset/Business.pm
> Line: 2321
> Payload:
>
> STACK:
>
> Trace begun at /usr/local/bricolage/lib/Bric/Biz/Asset/Business.pm
> line 2321
> Bric
> ::Biz
> ::Asset
> ::Business
> ::_init('Bric::Biz::Asset::Business::Media=HASH(0x14a51ad4)',
> 'HASH(0x1123c1e4)') called at /usr/local/bricolage/lib/Bric/Biz/Asset/
> Business.pm line 253
> Bric::Biz::Asset::Business::new('Bric::Biz::Asset::Business::Media',
> 'HASH(0x1123c1e4)') called at /usr/local/bricolage/lib/Bric/Biz/Asset/
> Business/Media.pm line 518
> Bric
> ::Biz
> ::Asset::Business::Media::new('Bric::Biz::Asset::Business::Media',
> 'HASH(0x1123c1e4)') called at /usr/local/bricolage/data/burn/sandbox/
> user_1029/oc_1/image_magick.mc line 89
> Bric::Util::Burner::Commands::__ANON__('element',
> 'Bric::Biz::Element::Container=HASH(0x1224d8c0)') called at /usr/local/
> lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm line 135
> HTML
> ::Mason
> ::Component::run('HTML::Mason::Component::FileBased=HASH(0xb7808a4c)',
> 'element', 'Bric::Biz::Element::Container=HASH(0x1224d8c0)') called
> at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 1256
> eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
> Request.pm line 1246
> HTML::Mason::Request::comp(undef, undef, 'element',
> 'Bric::Biz::Element::Container=HASH(0x1224d8c0)') called at /usr/local/
> bricolage/data/burn/comp/oc_1/press_release.mc line 60
> Bric::Util::Burner::Commands::__ANON__ at /usr/local/lib/perl5/
> site_perl/5.8.8/HTML/Mason/Component.pm line 135
> HTML
> ::Mason
> ::Component::run('HTML::Mason::Component::FileBased=HASH(0x11230118)')
> called at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm
> line 1256
> eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
> Request.pm line 1246
> HTML::Mason::Request::comp(undef, undef, undef) called at /usr/local/
> lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 915
> HTML
> ::Mason::Request::call_next('HTML::Mason::Request=HASH(0x1123bc74)')
> called at /usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm line 557
> Bric
> ::Util
> ::Burner
> ::Mason::chain_next('Bric::Util::Burner::Mason=HASH(0x1224d974)')
> called at /usr/local/bricolage/data/burn/comp/oc_1/autohandler line 120
> Bric::Util::Burner::Commands::__ANON__ at /usr/local/lib/perl5/
> site_perl/5.8.8/HTML/Mason/Component.pm line 135
> HTML
> ::Mason
> ::Component::run('HTML::Mason::Component::FileBased=HASH(0x12188418)')
> called at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm
> line 1251
> eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
> Request.pm line 1246
> HTML::Mason::Request::comp(undef, undef, undef) called at /usr/local/
> lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 460
> eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
> Request.pm line 460
> eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
> Request.pm line 412
> HTML::Mason::Request::exec('HTML::Mason::Request=HASH(0x1123bc74)')
> called at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Interp.pm
> line 342
> HTML::Mason::Interp::exec(undef, undef) called at /usr/local/bricolage/
> lib/Bric/Util/Burner/Mason.pm line 268
> eval {...} at /usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm line
> 268
> Bric
> ::Util
> ::Burner
> ::Mason::burn_one('Bric::Util::Burner::Mason=HASH(0x1224d974)',
> 'Bric::Biz::Asset::Business::Story=HASH(0x1224cc84)',
> 'Bric::Biz::OutputChannel=HASH(0xb7812eb0)',
> 'Bric::Biz::Category=HASH(0x12197ac0)') called at /usr/local/bricolage/
> lib/Bric/Util/Burner.pm line 1581
> Bric::Util::Burner::burn_one('Bric::Util::Burner=HASH(0x1224b1d8)',
> 'Bric::Biz::Asset::Business::Story=HASH(0x1224cc84)',
> 'Bric::Biz::OutputChannel=HASH(0xb7812eb0)',
> 'Bric::Biz::Category=HASH(0x12197ac0)') called at /usr/local/bricolage/
> lib/Bric/Util/Burner.pm line 967
> eval {...} at /usr/local/bricolage/lib/Bric/Util/Burner.pm line 919
> Bric::Util::Burner::preview('Bric::Util::Burner=HASH(0x1224b1d8)',
> 'Bric::Biz::Asset::Business::Story=HASH(0x1224cc84)', 'story', 1029,
> undef) called at /usr/local/bricolage/lib/Bric/App/Callback/Publish.pm
> line 117
> Bric
> ::App
> ::Callback
> ::Publish::preview('Bric::App::Callback::Publish=HASH(0x1124996c)')
> called at /usr/local/bricolage/comp/workflow/profile/preview/dhandler
> line 36
> HTML::Mason::Commands::__ANON__('checkout', 1, 'checkout', 1) called
> at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm line 135
> HTML
> ::Mason
> ::Component::run('HTML::Mason::Component::FileBased=HASH(0xad3a940)',
> 'checkout', 1, 'checkout', 1) called at /usr/local/lib/perl5/site_perl/
> 5.8.8/HTML/Mason/Request.pm line 1256
> eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
> Request.pm line 1246
> HTML::Mason::Request::comp(undef, undef, undef, 'checkout', 1,
> 'checkout', 1) called at /usr/local/lib/perl5/site_perl/5.8.8/HTML/
> Mason/Request.pm line 915
> HTML
> ::Mason
> ::Request
> ::call_next('HTML::Mason::Request::ApacheHandler=HASH(0x12196fb0)',
> 'checkout', 1) called at /usr/local/bricolage/comp/autohandler line 7
> HTML::Mason::Commands::__ANON__('checkout', 1) called at /usr/local/
> lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm line 135
> HTML
> ::Mason
> ::Component::run('HTML::Mason::Component::FileBased=HASH(0xa9675ec)',
> 'checkout', 1) called at /usr/local/lib/perl5/site_perl/5.8.8/HTML/
> Mason/Request.pm line 1251
> eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
> Request.pm line 1246
> HTML::Mason::Request::comp(undef, undef, undef, 'checkout', 1) called
> at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 460
> eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
> Request.pm line 460
> eval {...} at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
> Request.pm line 412
> HTML
> ::Mason
> ::Request
> ::exec('HTML::Mason::Request::ApacheHandler=HASH(0x12196fb0)') called
> at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/ApacheHandler.pm
> line 168
> HTML
> ::Mason
> ::Request
> ::ApacheHandler
> ::exec('HTML::Mason::Request::ApacheHandler=HASH(0x12196fb0)') called
> at /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/ApacheHandler.pm
> line 826
> HTML
> ::Mason
> ::ApacheHandler
> ::handle_request('HTML::Mason::ApacheHandler=HASH(0xa89a460)',
> 'Apache=SCALAR(0x1223c9b8)') called at /usr/local/bricolage/lib/Bric/
> App/Handler.pm line 314
> eval {...} at /usr/local/bricolage/lib/Bric/App/Handler.pm line 303
> Bric::App::Handler::handler('Apache=SCALAR(0x1223c9b8)') called at /
> dev/null line 0
> eval {...} at /dev/null line 0
>
> END DEBUGGING INFORMATION -->
>
--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret[at]pectopah.com
www.pectopah.com


rolfm at denison

Jul 21, 2008, 1:59 PM

Post #11 of 25 (916 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 21, 2008, at 1:41 PM, David E. Wheeler wrote:

> On Jul 21, 2008, at 08:31, Matt Rolf wrote:
>
>> The error we get is
>>
>> Cannot create an asset without an element type or alias ID
>>
>> And it points to the last line up there.
>>
>> Our code appears to work with images that are uploaded through the
>> interface, but not ones that are soaped in.
>>
>> We are also getting hashes for the %thumbnailInitialState and
>> %thumbnailElementType
>>
>> Any help is much appreciated, as we are in a bit of a bind.
>
> Can you send the full stack trace from the logs?


Ok, we have two errors - one from the stories, and one from the media.

Here is the code from the stories error, Lines 17-28.

#we're using the story_list utility template to grab the most recent
stories from all categories under the current one.
my @recentstories = $m->comp( 'story_list.mc', story_types =>
[qw(news_release)], all_subcats => 1, max => 20, site_ids => [$story-
>get_site_id]);
my $count = 0;
foreach my $rel (@recentstories) {

$count++;
if($count <= 12){
#we will check to see if the user entered a Teaser; if not, we'll use
the first 230 characters of the story for the teaser on the index page
my $text;

if($rel->get_data('teaser') eq ''){
$text = $rel->get_container('rich_paragraph')->get_data('paragraph');

And here is the stack trace:


<!-- DEBUGGING INFORMATION.

Error: Can&#39;t call method &quot;get_data&quot; on an undefined
value at /usr/local/bricolage/data/burn/comp/oc_1/news_list_print.mc
line 28, &lt;GEN4247&gt; line 502.


Fault Class: HTML::Mason::Exception
Description: generic base class for all Mason exceptions
Timestamp: 2008-07-21 13:47:45.000000
Package: HTML::Mason::Exceptions
Filename: /usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/
Exceptions.pm
Line: 129

STACK:

Can't call method "get_data" on an undefined value at /usr/local/
bricolage/data/burn/comp/oc_1/news_list_print.mc line 28, <GEN4247>
line 502.

Stack:
[/usr/local/bricolage/data/burn/comp/oc_1/news_list_print.mc:28]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
[/usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm:557]
[/usr/local/bricolage/data/burn/comp/oc_1/autohandler:120]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]

END DEBUGGING INFORMATION -->


rolfm at denison

Jul 21, 2008, 2:10 PM

Post #12 of 25 (917 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 21, 2008, at 4:39 PM, Bret Dawson wrote:

> Hi Matt.
>
> Hey, this looks like it's based on one of ours!

Yes, it is!

> Are you sure that your lookup for the thumbnail_photo element type is
> succeeding?

That's the problem - it's coming back as undefined, when in reality it
is there.

> There's a much more fully-featured version of this template now, if
> you're interested. When I have a moment to breathe I'll put it up on
> builidngbrics, but let me know if I should just post it here too.

We would love to see that!

-matt


bret at pectopah

Jul 21, 2008, 2:42 PM

Post #13 of 25 (913 views)
Permalink
Re: API Access of Updated Pages, plus templates [In reply to]

Hi Matt.

That's weird. I wonder why the element type lookup fails.

There are three pieces to this image stuff that we use.

The first is a template for a related-media subelement called
"feature_image". The idea is that you insert a feature_image in a story,
and upload a picture, and this is the template for that element.

The picture uploaded into feature_image is never actually displayed
anywhere. Images inside subelements of feature_image are, though. the
feature_image template names the desired subelements (in essence, the
desired set of large and small versions of the picture), and then calls
image_resize_and_relate, which makes those subelements and the pictures
to go inside them.

******
feature_image.mc

<%perl>
my %ratio;
my %element_names_and_sizes;

if (!$element->get_related_media) {
$burner->throw_error('One of the picture containers in the story "' . $story->get_title . '" is empty (it does not have an image file related to it). Please delete the container, or relate an image to it, and try again.');
}

%ratio = (
'height_aspect' => 2,
'width_aspect' => 3
);

%element_names_and_sizes = (
'article_image' => 520,
'slideshow_image' => 454,
'thumbnail_image' => 166
);

$m->comp('/util/image_resize_and_relate.mc',
'element_names_and_sizes' => \%element_names_and_sizes,
'needs_cropping' => \%ratio,
'publish_images_on_story_preview' => 'Yes',
'picture' => $element,
'target_image_element_type' => 'auto_generated_image',
'media_workflow' => Bric::Biz::Workflow->lookup({ name => 'Media' }),
'publish_desk' => Bric::Biz::Workflow::Parts::Desk->lookup({ name => 'Media Publish' })
);

my $article_image_container = $element->get_container('article_image');

if ($article_image_container->get_related_media) {
</%perl>

<div class="topimage" style="width: <% $article_image_container->get_related_media->get_value('width') %>px;">
<img src="<% $article_image_container->get_related_media->get_uri %>" alt="<% $element->get_value('caption') %>" width="<% $article_image_container->get_related_media->get_value('width') %>" height="<% $article_image_container->get_related_media->get_value('height') %>" />
<div class="caption"><% $element->get_value('caption') %></div>
</div><!--end topimage-->

% }

******

In image_resize_and_relate.mc, we actually make all the small pictures
we want, along with the container subelements, and we relate the
pictures to those containers

******
image_resize_and_relate.mc

<%args>
%element_names_and_sizes
%needs_cropping
$publish_images_on_story_preview
$picture
$target_image_element_type
$media_workflow
$publish_desk
</%args>
<%perl>
use Bric::Util::Time qw(:all);
use Date::Format;
use DateTime;

my $date = time;
my $formatted_date = strfdate($date);
# $m->out($formatted_date . '<br>');
# $m->out('Today is: ' . DateTime->now(time_zone => 'Canada/Eastern')->strftime("%Y/%m/%d") . '<br>');

my ($picture_is_good, $format, $scolding, $user, $new_media_document);

if (!$story->get_user__id) {
$user = Bric::App::Session->get_user_id;
} else {
$user = $story->get_user__id;
}

#pull out the media document inside the element and make sure it's a picture
if ($picture->get_related_media) {
$scolding = $m->scomp('/util/image_check.mc',
pic => $picture->get_related_media
);
if ($scolding) {
$m->out('<strong>' . $scolding . '</strong><br>');
} else {
$picture_is_good = 1;
$format = $burner->notes('ext');
$burner->notes( ext => '' );
}
}

if ($picture_is_good) {
my (%check_list, %safe_list);

#check for containers
foreach my $container_type(keys %element_names_and_sizes) {
foreach my $existing_container($picture->get_elements) {
if (($existing_container->get_key_name eq $container_type) && (!$check_list{$container_type})) {

#OK, we're working with this one
$check_list{$container_type} = 1;
$safe_list{$existing_container->get_id} = 1;
}
}
}

#kill any duplicate containers
foreach my $container_type(keys %element_names_and_sizes) {
foreach my $existing_container($picture->get_elements) {
if (($existing_container->get_key_name eq $container_type) && (!$safe_list{$existing_container->get_id})) {

#OK, we're deleting this one
my @killswitch;
$killswitch[0] = $existing_container;
$picture->delete_elements(\@killswitch);
$picture->save;
}
}
}

#create any missing containers
foreach my $container_type(keys %element_names_and_sizes) {
if (!$check_list{$container_type}) {
my $required_container_type = Bric::Biz::ElementType->lookup({ 'key_name' => $container_type });
$picture->add_container($required_container_type);
$picture->save;
}
}

#OK, we now have all the containers we need.
#Loop through them. If they already have pictures, leave them alone.
#If they don't have pictures, create them and relate them.
foreach my $working_container($picture->get_containers(keys %element_names_and_sizes)) {
if ($working_container->get_related_media) {
my $thumbScolding = $m->scomp('/util/image_check.mc',
pic => $working_container->get_related_media
);
if ($thumbScolding) {
#container has bad media file
$m->out('<strong>' . $thumbScolding . '</strong><br>');
} else {
#container has good media file, so leave it alone
}
} else {
#container is empty, so create image and relate it to container
my $target_element_type = Bric::Biz::ElementType->lookup({key_name => $target_image_element_type});

my $media_document_title = $picture->get_related_media->get_title . '-' . $working_container->get_key_name;

my %target_initial_state = (
'user__id' => $user,
'active' => 1,
'priority' => $story->get_priority,
'title' => $picture->get_related_media->get_title . '-' . $working_container->get_key_name,
'description' => '',
'workflow_id' => $media_workflow->get_id,
'element_type' => $target_element_type,
'site_id' => $story->get_site_id,
'source__id' => $picture->get_related_media->get_source__id,
'cover_date' => $formatted_date,
# 'media_type_id' => $picture->get_related_media->get_media_type->get_id,
'category__id' => $picture->get_related_media->get_category__id
);
my $new_file_name = $picture->get_related_media->get_file_name;
my $extension = "_$element_names_and_sizes{$working_container->get_key_name}.$format";
$new_file_name =~ s/....$/$extension/;
my $new_uri = $picture->get_related_media->get_primary_category->get_uri . DateTime->now(time_zone => 'Canada/Eastern')->strftime("%Y/%m/") . $new_file_name;

#check if there is already an image with the same URI in the Bricolage library.
#If there is, open that media document. Otherwise create a new one.
# $m->out('Looking for an existing media document with this uri:<br>' . $picture->get_related_media->get_primary_category->get_uri . time2str("%Y/%m/", $date) . $new_file_name . '<br>');
my @existing_media_document = Bric::Biz::Asset::Business::Media->list({
'uri' => $new_uri,
'active' => 1
});

if ($existing_media_document[0]) {
# $m->out('<br>Found existing one. URI is ' . $existing_media_document[0]->get_primary_uri . '<br>');
$new_media_document = $existing_media_document[0];
$new_media_document->checkout({ user__id => $user });
} else {
$new_media_document = Bric::Biz::Asset::Business::Media::Image->new(\%target_initial_state);
$new_media_document->set_workflow_id($media_workflow->get_id);
$new_media_document->save;

$publish_desk->accept({ asset => $new_media_document });
$publish_desk->save;

$new_media_document->checkin;
}


#Here we go, making the new image
my $temp_file = "/tmp/$new_file_name";
my $new_image = new Image::Magick;
$new_image->Read($picture->get_related_media->get_path);

if ($needs_cropping{'height_aspect'}) {
# $m->out('<br><br>Going to crop!');
my $target_height = int(($needs_cropping{'height_aspect'} * $picture->get_related_media->get_value('width')) / $needs_cropping{'width_aspect'});
$new_image->Crop( geometry => $picture->get_related_media->get_value('width')."x$target_height+0+0" );
# } else {
# $m->out('<br><br>NOT going to crop!');
}
$new_image->Thumbnail($element_names_and_sizes{$working_container->get_key_name});
$new_image->Set(colorspace=>'RGB');
$new_image->Write($temp_file);
undef $new_image;

#now upload our new image
my $file_handler;
open ($file_handler, "<$temp_file");

$new_media_document->upload_file($file_handler, $new_file_name, $picture->get_related_media->get_media_type->get_name);
#no need to close filehandler because upload_file does it automatically

#delete the temp image here
unlink ($temp_file);

#save and check in if required
$new_media_document->save;

if ($new_media_document->get_checked_out) {
# $publish_desk->checkin($new_media_document);
$new_media_document->checkin;
}

if ($publish_images_on_story_preview eq 'Yes') {
# $m->out('Got the go-ahead to publish images on preview<br><br>');
unless ($new_media_document->get_publish_status) {
# $m->out('Trying to publish "' . $new_media_document->get_title . '".<br>');
$burner->publish_another($new_media_document,$picture->get_related_media->get_cover_date,1);
}
}

#relate the image to the container
$working_container->set_related_media($new_media_document);
$working_container->save;
}
}
}
</%perl>
******

The last template is just a little thing to make sure the media file is
actually a picture.

******
image_check.mc

<%args>
$pic
</%args>
<%perl>
my %mediatypehash = %{$pic->get_media_type};
unless ($mediatypehash{'name'} eq "image/jpeg" || $mediatypehash{'name'} eq "image/jpg" || $mediatypehash{'name'} eq "image/gif" || $mediatypehash{'name'} eq "image/png") {
$m->print('I was expecting a JPG, GIF, or PNG here. Got something else.');
}
if (($mediatypehash{'name'} eq "image/jpeg") || ($mediatypehash{'name'} eq "image/jpg")) {
$burner->notes( ext => 'jpg' );
}
if ($mediatypehash{'name'} eq "image/gif") {
$burner->notes( ext => 'gif' );
}
if ($mediatypehash{'name'} eq "image/png") {
$burner->notes( ext => 'png' );
}
</%perl>
******

Hope this helps,

Bret


On Mon, 2008-07-21 at 17:10 -0400, Matt Rolf wrote:
> On Jul 21, 2008, at 4:39 PM, Bret Dawson wrote:
>
> > Hi Matt.
> >
> > Hey, this looks like it's based on one of ours!
>
> Yes, it is!
>
> > Are you sure that your lookup for the thumbnail_photo element type is
> > succeeding?
>
> That's the problem - it's coming back as undefined, when in reality it
> is there.
>
> > There's a much more fully-featured version of this template now, if
> > you're interested. When I have a moment to breathe I'll put it up on
> > builidngbrics, but let me know if I should just post it here too.
>
> We would love to see that!
>
> -matt
>
--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret[at]pectopah.com
www.pectopah.com


rolfm at denison

Jul 25, 2008, 5:40 AM

Post #14 of 25 (869 views)
Permalink
Re: API Access of Updated Pages, plus templates [In reply to]

So no one has had any errors like this? No clues in that stack trace?

Thanks,

Matt


lannings at who

Jul 25, 2008, 6:57 AM

Post #15 of 25 (871 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Mon, 21 Jul 2008, Matt Rolf wrote:
> my @recentstories = $m->comp( 'story_list.mc', story_types =>
> [qw(news_release)], all_subcats => 1, max => 20, site_ids =>
> [$story->get_site_id]);
> my $count = 0;
> foreach my $rel (@recentstories) {
[...]
> if($rel->get_data('teaser') eq ''){
[...]
> Error: Can&#39;t call method &quot;get_data&quot; on an undefined value at
> /usr/local/bricolage/data/burn/comp/oc_1/news_list_print.mc line 28,
> &lt;GEN4247&gt; line 502.

story_list.mc is presumably crappily coded
and is apparently sometimes returning undefined items.


smith_t at denison

Jul 28, 2008, 6:54 AM

Post #16 of 25 (862 views)
Permalink
Re: API Access of Updated Pages [In reply to]

I've tested it out and when it is erroring it is not returning undefined terms.

-Trevor

On Fri, Jul 25, 2008 at 9:57 AM, Scott Lanning <lannings[at]who.int> wrote:
> On Mon, 21 Jul 2008, Matt Rolf wrote:
>>
>> my @recentstories = $m->comp( 'story_list.mc', story_types =>
>> [qw(news_release)], all_subcats => 1, max => 20, site_ids =>
>> [$story->get_site_id]);
>> my $count = 0;
>> foreach my $rel (@recentstories) {
>
> [...]
>>
>> if($rel->get_data('teaser') eq ''){
>
> [...]
>>
>> Error: Can&#39;t call method &quot;get_data&quot; on an undefined value at
>> /usr/local/bricolage/data/burn/comp/oc_1/news_list_print.mc line 28,
>> &lt;GEN4247&gt; line 502.
>
> story_list.mc is presumably crappily coded
> and is apparently sometimes returning undefined items.
>


david at kineticode

Jul 29, 2008, 9:17 AM

Post #17 of 25 (841 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 21, 2008, at 13:59, Matt Rolf wrote:

> if($rel->get_data('teaser') eq ''){
> $text = $rel->get_container('rich_paragraph')->get_data('paragraph');
>
> And here is the stack trace:
>
>
> <!-- DEBUGGING INFORMATION.
>
> Error: Can&#39;t call method &quot;get_data&quot; on an undefined
> value at /usr/local/bricolage/data/burn/comp/oc_1/news_list_print.mc
> line 28, &lt;GEN4247&gt; line 502.

$rel doesn't have a rich_paragraph subelement. You need to check if it
ruturns C<undef> and skip it if it does.

HTH,

David


rolfm at denison

Jul 29, 2008, 10:16 AM

Post #18 of 25 (840 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 29, 2008, at 12:17 PM, David E. Wheeler wrote:

>> Error: Can&#39;t call method &quot;get_data&quot; on an undefined
>> value at /usr/local/bricolage/data/burn/comp/oc_1/
>> news_list_print.mc line 28, &lt;GEN4247&gt; line 502.
>
> $rel doesn't have a rich_paragraph subelement. You need to check if
> it ruturns C<undef> and skip it if it does.

Except that it does. There are rich_paragraph subelements in all these
stories.

-Matt


david at kineticode

Jul 29, 2008, 10:24 AM

Post #19 of 25 (843 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 29, 2008, at 10:16, Matt Rolf wrote:

>> $rel doesn't have a rich_paragraph subelement. You need to check if
>> it ruturns C<undef> and skip it if it does.
>
> Except that it does. There are rich_paragraph subelements in all
> these stories.

Check the return value. It's returning C<undef>.

David


rolfm at denison

Jul 29, 2008, 11:01 AM

Post #20 of 25 (842 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 29, 2008, at 1:24 PM, David E. Wheeler wrote:

> On Jul 29, 2008, at 10:16, Matt Rolf wrote:
>
>>> $rel doesn't have a rich_paragraph subelement. You need to check
>>> if it ruturns C<undef> and skip it if it does.
>>
>> Except that it does. There are rich_paragraph subelements in all
>> these stories.
>
> Check the return value. It's returning C<undef>.

But it doesn't return undef after we view the story in the interface.
Why would that be?

-Matt


rolfm at denison

Jul 29, 2008, 11:08 AM

Post #21 of 25 (842 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 25, 2008, at 9:57 AM, Scott Lanning wrote:

> story_list.mc is presumably crappily coded
> and is apparently sometimes returning undefined items.


Story list was taken directly from the bricolage test templates. All
it is returning is a list of the stories. As I stated earlier in the
thread, the stories are returned just fine. The problem is the fields
within those stories are unaccessable via api calls.

-Matt


david at kineticode

Jul 29, 2008, 11:10 AM

Post #22 of 25 (842 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 29, 2008, at 11:01, Matt Rolf wrote:

>> Check the return value. It's returning C<undef>.
>
> But it doesn't return undef after we view the story in the
> interface. Why would that be?

Dunno. Are you sure you spelled the key name correctly? And that
you're pulling the subelement from the proper element?

Best,

David


rolfm at denison

Jul 29, 2008, 11:16 AM

Post #23 of 25 (844 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 29, 2008, at 2:10 PM, David E. Wheeler wrote:

> Dunno. Are you sure you spelled the key name correctly?

Yep.

> And that you're pulling the subelement from the proper element?


Yep.

I strongly suspect this is a bug in bricolage. As I stated, we added
an element and then removed another one programmatically from these
stories using the api. The templates worked fine before that. After
that, they return undef on fields. But once we view a story through
the interface, the problem goes away. So what's happening in the
interface that doesn't happen when you check out and check in a story
through the api?

-Matt


rolfm at denison

Jul 29, 2008, 11:20 AM

Post #24 of 25 (842 views)
Permalink
Re: API Access of Updated Pages [In reply to]

This probably better explains the problem than what i just wrote.

-Matt

On Jul 19, 2008, at 3:11 AM, Matt Rolf wrote:

> We've updated some stories via the API and we've noticed that we can
> no longer access the elements or the fields in those stories via API
> methods in templates. Calls like get_primary_category still work,
> and even get_elements. But as soon as we try get_value,
> get_container, or get_data, all we are returned is "undefined",
> despite the fact that the containers are there and the data is quite
> clearly in the fields.
>
> Our update activity consisted of adding a field to the stories and
> removing another. We did not touch the fields we are currently
> trying to access. I can tell no noticeable difference between the
> story and story_instance fields of good and bad pages. Furthermore,
> story_field shows the correct number of instances.
>
> The problem goes away if a person checks out a story through the
> interface and checks it back in. At that point the story is able to
> be accessed again using the API call in templates. However,
> checking a story in and out *using* the API does not seem to have
> the same healing effect.
>
> Any suggestions for fixing this programatically? I'm not really
> looking forward to manually checking these stories out and in.
>
> Thanks,
>
> Matt


david at kineticode

Jul 29, 2008, 11:38 AM

Post #25 of 25 (845 views)
Permalink
Re: API Access of Updated Pages [In reply to]

On Jul 29, 2008, at 11:16, Matt Rolf wrote:

> I strongly suspect this is a bug in bricolage. As I stated, we
> added an element and then removed another one programmatically from
> these stories using the api. The templates worked fine before that.
> After that, they return undef on fields. But once we view a story
> through the interface, the problem goes away. So what's happening
> in the interface that doesn't happen when you check out and check in
> a story through the api?

Dunno, but it does sound like a bug. Can you reproduce it in a simple
test? If so, please do file a bug report if you haven't already.

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.