<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi John,<br>
       I think you must use something like this in your
      EP_TRIGGER_URL_REWRITE (this trigger, i think, can't control
      direct "render a screen"):<br>
      <br>
      <blockquote>my
$url="your_url_to_redirect_this_call_i_think_to_screen_EPrint::SecureSummary_plus_args";<br>
        EPrints::Apache::AnApache::send_status_line( $args{request},
        307, "Temporary Redirect" );<br>
        EPrints::Apache::AnApache::header_out( $args{request},
        "Location", $url );<br>
        EPrints::Apache::AnApache::send_http_header( $args{request} );<br>
        ${$args{return_code}} = EPrints::Apache::AnApache::DONE;<br>
        return EP_TRIGGER_DONE;<br>
      </blockquote>
      <br>
        Enio<br>
      <br>
      <br>
      Il 17/07/2014 13:43, John Salter ha scritto:<br>
    </div>
    <blockquote
cite="mid:EMEW3|a9c49a9c59189b01f6a2d14f87250cb5q6GDGs14eprints-tech-bounces|ecs.soton.ac.uk|7154BCBB8909D642AE6F44CA713DBC2009A4D06FB116@HERMES7.ds.leeds.ac.uk"
      type="cite">
      <pre wrap="">Hi Seb,
Thanks for the reply, sorry for the delay in getting back to you.

I'm still not sure I understand how to get where I need to be - here's what I'm trying to do:
 - intercept a request for an EPrint - the rewrite trigger matches a URL e.g. <a class="moz-txt-link-freetext" href="http://repo/123/">http://repo/123/</a> with '^/(\d+)/$'.  *
 - check (with the new Access Control stuff we're working on :o) whether the request can view the item**
 - if the request is permitted to view, render a variant of the EPrint::Summary screen, EPrint::SecureSummary
 - if it can't, let EPrints do it's normal thing - which in this case will direct to a summary page with minimal metadata.

* I don’t want to redirect from <a class="moz-txt-link-freetext" href="http://repo/123/">http://repo/123/</a> to <a class="moz-txt-link-freetext" href="http://repo/cgi/">http://repo/cgi/</a>[something],
**There may not be a 'user' at this point in time - there could be an IP-based 'allow'.

Below is what I've got so far for my trigger - I've tried various things - either resulting in a login page, a 404 error or a smoking server...

$c-&gt;add_trigger( EP_TRIGGER_URL_REWRITE, sub
{
        my( %args ) = @_;

        my( $repository, $uri, $return_code, $request ) = @args{ qw( repository uri return_code request ) };
        if( defined $uri &amp;&amp; ($uri =~ m# ^/(\d+)/$ #x ) )
        {
                my $eprintid = $1;
                my $eprint = $repository-&gt;dataset( "eprint" )-&gt;dataobj( $eprintid );
                # this is an overridden 'permit' that does some new things, but still returns a '1' or '0'.
                my $can_view = $eprint-&gt;permit( "eprint/view", $repository-&gt;current_user ); #NB current_user may be undef
                if( $can_view ){
                        #render the EPrint::SecureSummary screen
                        #and set the return code?
                        # ${$return_code} = EPrints::Const::OK;
                        #return EP_TRIGGER_DONE;
                }
        }
        return EP_TRIGGER_OK;

}, priority =&gt; 100 ); 

Any (further) thoughts welcomed!
Cheers,
John


-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">eprints-tech-bounces@ecs.soton.ac.uk</a> [<a class="moz-txt-link-freetext" href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">mailto:eprints-tech-bounces@ecs.soton.ac.uk</a>] On Behalf Of Sebastien Francois
Sent: 11 July 2014 11:37
To: <a class="moz-txt-link-abbreviated" href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a>
Subject: [EP-tech] Re: EP_TRIGGER_URL_REWRITE and redirecting to a screen

Hi John,

I don't think that case (1) redirects - see eprints3/cgi/users/home. It 
just passes on the request to the ScreenProcessor. You could achieve the 
same with a trigger in fact.

Since your screen already has a url 
(<a class="moz-txt-link-freetext" href="http://repo/cgi/users/home?screen=MyScreen">http://repo/cgi/users/home?screen=MyScreen</a>), I guess what you want to 
do is a rewrite as in mod_rewrite.

Seb.

On 11/07/14 11:16, John Salter wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Hi,
What's the *best/intended* way to go from an  EP_TRIGGER_URL_REWRITE trigger to a screen?

&gt;From searching the Bazaar, is seems like most things like this either:
(1) use a cgi/... script that does the screen selection/processing, or
(2) register a handler that does the work (e.g.  $request-&gt;set_handlers(PerlResponseHandler =&gt; [ 'EPrints::Plugin::MePrints::MePrintsHandler' ] ); )

Both seem not-quite-right: (1) requires the trigger to do a redirect (another HTTP call), (2) would duplicate a lot of stuff that EPrints does 'normally' (the screen I want to use is a normal EPrints screen).

Should the trigger should be able to do the work?
Have I missed some magic way of doing this?

Cheers,
John



*** Options: <a class="moz-txt-link-freetext" href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a>
*** Archive: <a class="moz-txt-link-freetext" href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a>
*** EPrints community wiki: <a class="moz-txt-link-freetext" href="http://wiki.eprints.org/">http://wiki.eprints.org/</a>
*** EPrints developers Forum: <a class="moz-txt-link-freetext" href="http://forum.eprints.org/">http://forum.eprints.org/</a>
</pre>
      </blockquote>
      <pre wrap="">
*** Options: <a class="moz-txt-link-freetext" href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a>
*** Archive: <a class="moz-txt-link-freetext" href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a>
*** EPrints community wiki: <a class="moz-txt-link-freetext" href="http://wiki.eprints.org/">http://wiki.eprints.org/</a>
*** EPrints developers Forum: <a class="moz-txt-link-freetext" href="http://forum.eprints.org/">http://forum.eprints.org/</a>

*** Options: <a class="moz-txt-link-freetext" href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a>
*** Archive: <a class="moz-txt-link-freetext" href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a>
*** EPrints community wiki: <a class="moz-txt-link-freetext" href="http://wiki.eprints.org/">http://wiki.eprints.org/</a>
*** EPrints developers Forum: <a class="moz-txt-link-freetext" href="http://forum.eprints.org/">http://forum.eprints.org/</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>