[Dbix-class] Adding Class::Workflow data to a DBIx::Class object
Christopher H. Laco
claco at chrislaco.com
Wed Oct 3 19:23:45 GMT 2007
Ian Docherty wrote:
> I am using Moose, but I don't think that is the problem.
> =
> I want to over-ride 'new' whenever I create a 'Demo' object and add a
> Class::Workflow object to my DBIx::Class object. My code is:-
> ----------------
> package MyApp::Domain::Result::Demo;
> =
> use Moose;
> use Class::Workflow;
> =
> BEGIN {
> extends 'DBIx::Class';
> };
> =
> has 'workflow' =3D> (
> is =3D> 'rw',
> isa =3D> 'Class::Workflow',
> );
> =
> __PACKAGE__->load_components(qw(PK::Auto Core));
> __PACKAGE__->table('demo');
> __PACKAGE__->add_columns(qw(id name value state creator owner));
> __PACKAGE__->set_primary_key('id');
> =
> sub new {
> my ($class, $attrs) =3D @_;
> =
> my $workflow =3D Class::Workflow->new;
> my $new =3D $class->next::method($attrs);
> =
> # Neither of the following two work, both give the same error (see below)
> $new->{workflow} =3D $workflow;
> $new->workflow($workflow);
> }
> ----------------
> =
> Both the ways I try to add the $workflow object (or any other data type
> actually) gives an error similar to the following.
> =
> Caught exception in MyApp::Web::Controller::Workflow::Intro->index
> "Can't locate object method "insert" via package "Class::Workflow"
> at /usr/lib/perl5/site_perl/5.8.8/DBIx/Class/ResultSet.pm line 1553."
> =
> I can create a Class::Workflow object outside of DBIx::Class without any
> problem. I just can't combine the two.
> =
> Any ideas?
> =
> Regards
> Ian
While I have no answer to your problem (try inflate_result instead?)...
Just out of curiosity, what ya doing combining the two. Sounds interesting.
-=3DChris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20071003/ab=
69d86b/signature.pgp
More information about the DBIx-Class
mailing list