Greetings monks,

I am trying to use the cpan Workflow module but despite having read (and reread) the docs seem to be coming unstuck on what I think is a basic lack of my understanding of OO Perl, Im hoping some experienced monks might be able to point me in the right direction ....
just as a simple test example to upload a file I have a workflow xml:
<workflow type="uplfile" persister="Filesystem"> <time_zone>local</time_zone> <description>This is the Blast sequence alignment workflow.</desc +ription> <state name="INITIAL" autorun="yes"> <action name="upload file" resulting_state="uploaded" /> </state> <state name="uploaded" autorun="yes"> <action name="null" resulting_state="finished"> </action> </state> <state name="finished" /> </workflow>
and a corresponding action.xml
<actions> <type>uplfile</type> <action name="upload file" class="myapp::Upload_file"> </action> <action name="null" class="Workflow::Action::Null" /> </actions>
in the myapp subdirectory there is an Upload_file.pm which simply opens up and prints out a short text sequence:
package Upload_file; use strict; use Fcntl; use base qw( Workflow::Action ); use Workflow::Exception qw( workflow_error ); sub new { my $class = shift; my $self = {}; bless ($self, $class); return $self; } sub execute { my ( $self, $wf ) = @_; my $ifile = "/mypath/to/codelib/perl/lib/myapp/testseq.txt"; sysopen(IFILE, $ifile, O_RDONLY) or die "Can't open $ifile : $!"; my @file = <IFILE>; close IFILE; print "testseq is ", @file, "\n"; return 1; } 1;

when I try and execute this action from the calling script:
#! /bin/perl -w use strict; use Workflow::Factory qw( FACTORY ); use Fcntl; use File::Basename; Log::Log4perl::init('l4p.conf'); my $workflow_conf = 'wf_test.xml'; my $action_conf = 'action.xml'; my $pers = 'persister.xml'; FACTORY->add_config_from_file( workflow => $workflow_conf, action => $action_conf, persister => $pers, ); my $wf = FACTORY->fetch_workflow('uplfile', "PITGKDNR"); print "Workflow 1 ", $wf->id, " ", "currently at state ", $wf->state, "\n"; print "Available actions: ", $wf->get_current_actions, "\n"; $wf->execute_action('upload file');

the execute action fails:
Workflow 1 PITGKDNR currently at state INITIAL Available actions: upload file Can't locate object method "new" via package "myapp::Upload_file" at / +lib/x86_64/pkg/perl-5.8.8/lib/site_perl/5.8.8/Workflow/Factory.pm lin +e 546.

but there is a new method in the Upload_file package, and if I call
Upload_file->new()->execute();

instead I get the text from the file (but not via the workflow of course)...

In reply to Workflow module problem by diomedea

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.