[Perl-workflow-devel] Persister::DBI subclassing issues
Brought to you by:
jonasbn
From: Jim B. <cb...@bu...> - 2007-07-10 17:30:19
|
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 |