Re: [EP-underground] Questions about subjects

Alan Schmitz <[email protected]> Tue, 11 Feb 2003 15:03:04 -0600
Newsgroups gmane.comp.web.eprints.general
Message-ID <[email protected]>
Eventually I figured out that I needed a subject object, and I came up with 
the code you've listed below.  Now I can get to the screen to add 
bibliographic information, but I get another error when I hit the "next" 
button:

    Can't call method "get_db" on an undefined value at
    /usr/local/eprints/perl_lib/EPrints/Subject.pm line 172.

I know the subject ID is valid, because I can print it to STDERR.  The 
session appears to be blank when I print it to STDERR.  I would expect to 
see a hash or array reference here.  Where does $session come from, if it's 
not passed to the set_eprint_automatic_fields function?

Thanks,
Alan Schmitz

-----
SILO Project Coordinator
State Library of Iowa


At 12:35 PM 2/10/2003 +0000, you wrote:
>oh, my bad!
>
>The $subj is an id string, not a subject object
>
>change:
>
>         foreach my $subj ( @{$searchsubjects} )
>         {
>                 $stext .= EPrints::Utils::tree_to_utf8(
>                                 $subj->render_description )." ";
>         }
>to
>         foreach my $subj_id ( @{$searchsubjects} )
>         {
>                 my $subj = EPrints::Subject->new( $session, $subj_id );
>                 $stext .= EPrints::Utils::tree_to_utf8(
>                                 $subj->render_description )." ";
>         }
>
>On Sun, Jan 26, 2003 at 04:15:09 -0600, Alan Schmitz wrote:
> > A couple of months ago I asked a question about subject keyword
> > searches in E-Prints.  Chris Gutteridge responded with the field
> > definitions and code below.  I'm finally getting around to implementing
> > his suggestion which includes using a new text field for subject
> > keywords.
> >
> > The code works until it tries to call the "render_description"
> > function.  Perl gives the following error, 'Can't call method
> > "render_description" on unblessed reference'.
> >
> > I've also tried to make a new subject object from the subject ID, but I
> > don't know what I'm supposed to pass for the session parameter.  What
> > do I need to do so I can call "render_description", or how do I make a
> > new subject object from a subject ID?
> >
> > Thanks,
> > Alan Schmitz
> >
> > ----
> > SILO Project Coordinator
> > State Library of Iowa
> >
> > > { name => "searchsubjects", type=>"subject", top=>"subjects", multiple
> > > => 1, browse_link => "subjects" },
> > >
> > > { name => "subjectstext", type => "longtext" },
> > >
> > > we'd make the following trigger
> > >
> > > sub set_eprint_automatic_fields
> > > {
> > >     my( $eprint ) = @_;
> > >     my $searchsubjects = [];
> > >     my $setall = 0;
> > >     foreach my $subjid ( $eprint->get_value( "subjects" ) )
> > >     {
> > >             push @{$searchsubjects}, $subjid;
> > >             if( $subjid eq "all" ) # or whatever the key for the ALL 
> field is
> > >             {
> > >                     $setall = 1;
> > >             }
> > >     }
> > >
> > >     # set ALL the searchsubjects if the flag is set
> > >     if( $setall )
> > >     {
> > >             foreach my $subjid (
> > >                     "dallas",
> > >                     "foo",
> > >                     "baz",
> > >                     "fnord",
> > >                     "bar" )
> > >             {
> > >                     push @{$searchsubjects}, $subjid;
> > >             }
> > >     }
> > >
> > >     $eprint->set_value( "searchsubjects", $searchsubjects );
> > >
> > >     my $stext = "";
> > >     foreach my $subj ( @{$searchsubjects} )
> > >     {
> > >             $stext .= EPrints::Utils::tree_to_utf8(
> > >                             $subj->render_description )." ";
> > >     }
> > >     $eprint->set_value( "subjectstext", $stext );
> > > }
>
>--
>
>  Christopher Gutteridge                   [email protected]
>  ePrints2 Coder, Support and Stuff        +44 23 8059 4833