Hi Jim,
Thanks for sharing. It seems as if we have general problems with
subclassing of some of the core classes.
I will put this on the task list, since I think it should be easier
to subclass persisters among other things.
jonasbn
On 10/07/2007, at 19.30, Jim Brandt wrote:
>
> I've just finished subclassing Workflow::DBI::Persister and ran into a
> few problems I wanted to share. Don't have any specific solutions just
> yet, just my work-arounds:
>
> 1) I don't think you can actually just subclass as shown here:
>
> http://search.cpan.org/~jonasbn/Workflow-0.26/lib/Workflow/
> Persister/DBI.pm
>
> unless you call SUPER::init because you'll get a $log not defined
> error
> when the code hits assign_generators. This is because the $log ||=
> get_logger is below the first $log call. I think if it gets moved up,
> the problem will be fixed:
>
> sub assign_generators {
> my ( $self, $params, $driver ) = @_;
> $log ||= get_logger();
> $log->is_debug &&
> $log->debug( "assign_generators with $self, $params,
> $driver" );
> $self->SUPER::assign_generators( $params );
> return if ( $self->workflow_id_generator and
> $self->history_id_generator );
>
> move this up --> $log ||= get_logger();
> my ( $wf_gen, $history_gen );
>
> 2) I think the 'assign_generators' example on the page has the params
> backwards. It shows:
>
> $self->assign_generators( $ds_config->{driver_name}, $params );
>
> But I think that method wants $params first.
>
> 3) There doesn't seem to be an easy way to subclass the Persister and
> use ExtraData at the same time. I did it by subclassing ExtraData.pm,
> but I had to copy most of init and chop out a few things since I
> didn't
> want to call SUPER::init.
>
> Maybe pull out the parts that load the extra values into a separate
> sub
> so if you subclass you just need to add a call to:
>
> $self->load_extra_data();
>
> to your init? Just a thought. I'm sure there are other solutions.
>
> As I said, sorry I don't have actual patches right now. I just
> wanted to
> capture the info while it was fresh.
>
>
> Jim
>
>
> --
> Jim Brandt
> Administrative Computing Services
> University at Buffalo
>
>
>
> ----------------------------------------------------------------------
> ---
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Perl-workflow-devel mailing list
> Per...@li...
> https://lists.sourceforge.net/lists/listinfo/perl-workflow-devel
|