Re: [greenstone-users] Build error with GenericList classifier

From Katherine Don
DateTue, 28 Feb 2006 17:08:36 +1300
Subject Re: [greenstone-users] Build error with GenericList classifier
In-Reply-To (43FC6EA0-3030900-yale-edu)
Hi Arthur

Yes, the way arguments are parsed is different now. The easiest thing to
do is to look at another plugin (e.g. HTMLPlug) and copy the code.

You need to define the arguments:
my $arguments =
[ { 'name' => "process_exp",
'desc' => "{BasPlug.process_exp}",
'type' => "regexp",
'deft' => &get_default_process_exp() },
.....
];

the options:
my $options = { 'name' => "HTMLPlug",
'desc' => "{HTMLPlug.desc}",
'abstract' => "no",
'inherits' => "yes",
'args' => $arguments };

The 'new' method changes to:

sub new {
my ($class) = shift (@_);
my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
push(@$pluginlist, $class);

if(defined $arguments){
push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};


my $self = (defined $hashArgOptLists)? new
BasPlug($pluginlist,$inputargs,$hashArgOptLists): new
BasPlug($pluginlist,$inputargs);

# if you need to set up other fields, objects etc, do it here.

return bless $self, $class;
}


All the arguments are saved as fields in the object with the same name.

e.g. the process_exp option will be saved as $self->{'process_exp'}.
So be careful if you have used different names in your arguments as in
your $self->{'xxx'} fields.

Regards,
Katherine

Arthur R. Belanger wrote:
> I have gotten a similar error when using a locally developed plugin that
> works fine with version 2.50 when I tried to use it in 2.62. I added a
> "use diagnostics;" statement to pluginfo.pl (2.62) to get the following
> detailed error message:
>
> Can't coerce array into hash at
> /usr/local/gsdl/perllib/plugins/BasPlug.pm line
> 376 (#1)
> (F) You used an array where a hash was expected, but the array has no
> information on how to map from keys to array indices. You can do that
> only with arrays that have a hash reference at index 0.
> Uncaught exception from user code:
> Can't coerce array into hash at
> /usr/local/gsdl/perllib/plugins/BasPlug.pm
> line 376.
> at /usr/local/gsdl/perllib/plugin.pm line 67
> plugin::load_plugin_for_info('DCPlug') called at
> /usr/local/gsdl/bin/scrip
> t/pluginfo.pl line 176
> main::main() called at /usr/local/gsdl/bin/script/pluginfo.pl
> line 211
>
> Line 376 of BasPlug.pm is:
> if(defined $arguments){
> push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
>
> Was there some basic change in the way arguments are passed to plugins
> (and classifiers) between 2.50 and 2.6x? If so, can you tell my what I
> may need to do to convert my plugin to work with 2.6x?
>
> Thanks very much
>
>
> Chaitra Rao wrote:
>
>> Hi, I'm unable to use GenericList classifier bundled with the greenstone
>> installation (v2.62).
>> I get the foll error while building: Command: E:Program
>> Filesgs2.62binwindowsperlbinPerl.exe -S E:Program
>> Filesgs2.62binscriptbuildcol.pl -gli -language en -collectdir
>> E:Program Filesgs2.62collect -removeold aaqua buildcol.pl> Can't
>> coerce array into hash at E:Program
>> Filesgs2.62/perllib/classify/BasClas.pm line 234.
>> buildcol.pl> Command failed.
>>
>> The line no. 234 on BasPlug.pm corresponds to the foll line:
>> if(defined $arguments){
>> push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
>>
>> Please help!
>> Thanks in advance
>> Regards,
>> Chaitra
>>
>> _______________________________________________
>> greenstone-users mailing list
>> greenstone-users@list.scms.waikato.ac.nz
>> https://list.scms.waikato.ac.nz/mailman/listinfo/greenstone-users
>>
>>
>>
>