EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #02492


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

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


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.