EPrints Technical Mailing List Archive

Message: #07962


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

Re: [EP-tech] Action upon Lifting Embargo


Hello again,

I managed to make EPrints do what I wanted. Most of you will know how to do this I imagine, but if anybody relatively new to EPrints is curious, here is how I did it (no guarantees that this is the best way to do it!).

I looked in lift_embargos and found:

# post-processing, eg. send notification of embargo expiry
if( $session->can_call( "notify_embargo_expiry" ) )
{
$session->call( "notify_embargo_expiry", $eprint, $doc );
}

So, being a lazy bones and completing a million greps to establish I didn't have a pre-existing "notify_embargo_expiry" function I wrote my own in a .pl file in archives/*archive_id*/cfg/cfg.d:

$c->{notify_embargo_expiry} = sub
{
use LWP::Authen::OAuth;

and so on...

Beware of calling any perl modules that aren't in the core EPrints files; lift_embargos (my version at least) has:

use lib "$FindBin::Bin/../perl_lib";

This prevented LWP::Authen::OAuth from being loaded, but because this module has "@ISA = qw( LWP::UserAgent );" it went straight to that without loading the intended module. This then allowed the script to run and successfully complete, but gave warnings on the command line as some of the properties passed to it were not expected.

To get around that I just changed the top of lift_embargos to:

use FindBin;
use LWP::Authen::OAuth;
use lib "$FindBin::Bin/../perl_lib";

including the module before the use lib call. It doesn't seem to have broken anything so I'm happy. We now have tweets and the ability to process some metadata to make useful hashtags!

I borrowed heavily from:


Adding some bits (like hashtag stuff from keywords) and removing others (I think the link shortening was giving me some grief and appears to be unnecessary on Twitter now). 

Thanks,
James




On Mon, Sep 2, 2019 at 1:08 PM James Kerwin via Eprints-tech <eprints-tech@ecs.soton.ac.uk> wrote:
Hi All,

I have yet another, probably simple, question to ask.

I have a script that does something (sends a tweets if anybody is interested...) on an EPrint status change using:

$c->{eprint_status_change} = sub {

It quickly escapes if an item has an embargo on it. I then want a slightly different version of the same script to run when embargoes are lifted.

Is there a way to make this happen? I'm currently looking at bin/lift_embargos and seeing where I can drop a call to my script in there. I was wondering if there was a better or more proper way to make this happen?

I have tried to look at the EPrints documentation, but not managed to find what I want.

Thanks,
James
*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/