Core API

From EPrints Documentation
Revision as of 19:43, 11 August 2009 by Tdb01r (talk | contribs)
Jump to: navigation, search


This is the bits which you will need to get started...

A connection to the EPrints system is represented by an instance of EPrints::Session. The session object links to

And if a CGI script then also

If you're writing your own script then you'll need to start by asking for a Session object.

Command-line Script

#!/usr/bin/perl -w -I/opt/eprints3/perl-lib/

use EPrints;

use strict;

my $archive_id = $ARGV[0];
my $session = new EPrints::Session( 1, $archive_id );
exit( 1 ) unless( defined $session );
# do your stuff

The "1" passed to Session tells it that we're a normal script and not a CGI script.

The $archive_id value is taken from $ARGV[0] which is the first parameter on the commandline. You could hard-wire the value if you wanted.

The use of "-w" to produce warnings and "use strict" to prevent sloppy code is just good Perl-practice.

CGI Script

This is similar to a command line script but you don't need the path to perl and the archive_id is not needed as it will work that out from the web-request.

use EPrints;
use strict;
my $session = new EPrints::Session;
exit( 0 ) unless( defined $session );
# do some stuff
# Return a result to browser (usually an HTML page)


Code in the EPrints Configuration Files

Such as or creating a new subroutine for render_single_value on a field.

These are always passed a $session so you don't need to create your own.


These are described in the section about plugins.