[EP-tech] Adding methods to EPrints::Database

Ian Stuart Ian.Stuart at ed.ac.uk
Thu Dec 12 11:52:59 GMT 2013


OK, I'm doing "hinky stuff" with additional tables in the EPrints 
database (primarily using them for records that are not part of the 
EPrints application)

The basic idea is to extend EPrints::Database - as described in 
http://stackoverflow.com/questions/14047407/extending-perl-module-from-within-the-calling-script

So, in an EPrints::DataObj::VisitorTickets package (which describes the 
additional tables) I have

===== start code ======
use EPrints::Database;
sub EPrints::Database::update_visitor_ticket
{
	my( $self, $code, $user_id ) = @_;
	my $table = "visitorticket";

	my $Q_table   = $self->quote_identifier( $table );
	my $Q_user_id = $self->quote_identifier( "userid" );
	my $Q_code    = $self->quote_identifier( "code" );

	my $sql = "DELETE FROM $Q_table WHERE 
$Q_userid=".$self->quote_int($userid)." AND 
$Q_code=".$self->quote_value($code);
	$self->do($sql);

	$self->insert( $table, ["code","userid","expires"], [
		$code,
		$userid,
		time()+3600
	]);

}
===== end code ======

and then in my script I have:

===== start code =====
$repo->{'database'}
       ->update_visitor_ticket( $eprints_session, $secret_code, 
$visitor_id );
===== end code =====

My problem is that, when I run the script that calls this, I get the error:
   Can't locate object method "update_visitor_ticket" via package
   "EPrints::Database::Pg"

Now - given that EPrints::Repository has the code
===== start code =====
	my $userid = $user->get_id;
	$self->{database}->update_ticket_userid( $code, $userid, $ip );
===== end code =====
and works... I don't understand why EPrints::Repository works, and my 
package doesn't...

Any ideas?

-- 

Ian Stuart.
Developer: ORI, RJ-Broker, and OpenDepot.org
Bibliographics and Multimedia Service Delivery team,
EDINA,
The University of Edinburgh.

http://edina.ac.uk/

This email was sent via the University of Edinburgh.

The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



More information about the Eprints-tech mailing list