Re: Mapping package states with different code ref names

Josh803316 <[email protected]>
Newsgroups gmane.comp.lang.perl.poe
Message-ID <[email protected]>
To answer my own question......always helps to read the
documentation.......I was using the [ ]  shorthand form which maps identical
names

THIS:
(__PACKAGE__) => [
                 '_start' => '_start',
                 '_stop'  => '_stop',
                 (map { $_ => '_process_request' } keys %COMMANDS)
             ],
             ($class)       => [
                 'find' => '_process_request'
             ]

SHOULD BE:

 (__PACKAGE__) => {
                 '_start' => '_start',
                 '_stop'  => '_stop',

                 (map { $_ => '_process_request' } keys %COMMANDS)
             },
             ($class)       => {
                 'find' => '_process_request'
             }



On Thu, May 7, 2009 at 9:56 PM, Josh803316 <[email protected]> wrote:

> For some reason......when I execute the find method, which should really
> execute the '_process_request' method the find isn't replaced with a
> reference to _process_request
>
> #############  CODE ATTEMPT #########
> my $session = $class->__spawn({easyDBI_alias => 'easydbi_alias'});
> $kernel->post('PoeDevice', find => { id => 1, find_event =>
> \&my_method_handler } );
> ######################################
>
> ## find and any keys of %command should all be mapped to _process_request
> but they aren't  any ideas why?
> sub __spawn {
>
>     my $class = shift;
>     my %exp_commands = map { $_ => 1 } qw(find);
>     my $session = POE::Session->create(
>
>         package_states =>
>           [
>              (__PACKAGE__) => [
>                  '_start' => '_start',
>                  '_stop'  => '_stop',
>                  (map { $_ => '_process_request' } keys %COMMANDS)
>              ],
>              ($class)       => [
>                  'find' => '_process_request'
>              ]
>
>           ],
>         ## pass args into _start:
>         args => [@_],
>         heap => {
>             class => $class
>         },
>
>     );
>
>     return $session;
>
> }
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.