[Catalyst] Jason Kohles' tutorial on ExtJs editable data gridsandCatalyst

jagdish eashwar jagdish.eashwar at gmail.com
Fri May 1 09:26:32 GMT 2009


Hi Adam,

I have these two controllers whose code differs chiefly in respect of the
table being accessed.
The two tables (Affiliation and People) have a reciprocatory 'has_many' /
'belongs_to' relationship. While the affiliation_data sub works, the
people_data sub doesn't. The error message I'm getting for the people_data
sub inclines me to think that the 'allow_blessed' / 'convert_blessed'
features have to be enabled when a table has a 'belongs_to' relationship. I
don't know how to do that.

=3Dhead2 people_data

=3Dcut

sub people_data : Local {
      my ( $self, $c ) =3D @_;

      my $rs =3D $c->model( 'AdventAjaxGrid2DB::People' );
      my @people =3D ();
      while ( my $person =3D $rs->next ) {
          push( @people, {
              id          =3D> $person->id,
              name        =3D> $person->name,
              affiliation_id =3D> $person->affiliation_id,
          } );
      }
      $c->stash->{ 'people_stash' } =3D \@people;
      $c->detach( $c->view( 'JSON' ) );
  }

=3Dhead2 affiliation_data

=3Dcut

sub affiliation_data : Local {
    my ($self, $c) =3D @_;

    my $rs =3D $c->model('AdventAjaxGrid2DB::Affiliation');
    my @affiliations =3D ();
    while (my $affiliation  =3D $rs->next) {
        push(@affiliations, {
            affiliation_id =3D> $affiliation->affiliation_id,
            affiliation_name =3D> $affiliation->affiliation_name
            });
        }
    $c->stash->{'affiliation_stash'} =3D \@affiliations;
    $c->detach($c->view('JSON'));
    }


On Thu, Apr 30, 2009 at 10:04 PM, Adam Witney <awitney at sgul.ac.uk> wrote:

> The error I get is :
>> "[error] Caught exception in AdventAjaxGrid2::View::JSON->process
>> "encountered object
>> 'AdventAjaxGrid2::Model::AdventAjaxGrid2DB::Affiliation=3DHASH(0x91b8270=
)',
>> but neither allow_blessed nor convert_blessed settings are enabled at
>> /usr/local/share/perl/5.8.8/JSON/Any.pm line 426."
>>
>> I couldn't figure out how to enable those settings from the JSON-Any wri=
te
>> up on CPAN. How is that to be done?
>>
>
> from my limited experience, this seems to come up when you are not sending
> proper JSON to the JSON view. Check the code before the line:
>
> $c->detach( $c->view( 'JSON' ) );
>
> to see what you are sending it (The error suggests you are pushing an
> object to it, in the calendar example he sends a reference to an array of
> hashes).
>
> HTH
>
> adam
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090501/660cc=
789/attachment.htm


More information about the Catalyst mailing list