<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hola,<br>
      <br>
      I think you can pass on the ScreenProcessor / a Screen from your
      trigger.<br>
      <br>
      Something like:<br>
      <pre wrap="">$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 ){

                        $r-&gt;set_handlers( PerlResponseHandler =&gt; sub {

                                my( $r ) = @_;                                                # if needed
                                my $repository = <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">$EPrints::HANDLE-&gt;current_repository;        # if needed<pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; white-space: pre-wrap;"></pre>                                EPrints::ScreenProcessor-&gt;process(
                                        repository =&gt; $repository,
                                        screenid =&gt; "YourScreenID",
        
                                        # ... whatever other params your Screen needs ....
                                );

                                return HTTP_OK;

                        } );

                        $$return_code = EPrints::Const::OK;
                        return EP_TRIGGER_DONE;

                &nbsp;}
        }
        return EP_TRIGGER_OK;

}, priority =&gt; 100 ); 
</pre>
      <br>
      Alternatively, you can have an actual Perl Response Handler, you
      can use as templates:<br>
      <br>
      -
      <a class="moz-txt-link-freetext" href="http://bazaar.eprints.org/325/1/epm/meprints/cfg/cfg.d/z_meprints.pl">http://bazaar.eprints.org/325/1/epm/meprints/cfg/cfg.d/z_meprints.pl</a>
      (search for
      <meta http-equiv="content-type" content="text/html;
        charset=ISO-8859-1">
      EP_TRIGGER_URL_REWRITE)<br>
      -
      <a class="moz-txt-link-freetext" href="http://bazaar.eprints.org/325/1/plugins/EPrints/Plugin/MePrints/MePrintsHandler.pm">http://bazaar.eprints.org/325/1/plugins/EPrints/Plugin/MePrints/MePrintsHandler.pm</a>
      (the handler can do whatever you want, you can print the page to
      STDOUT, or let the ScreenProcessor do that for you).<br>
      <br>
      And just, as a small add-on, on some ACL work I was looking at, my
      main method was called permit_action (on DataObj) and you pass the
      action as a param so that it looks like:<br>
      <br>
      my $rc = $dataobj-&gt;permit_action( "view", $current_user ); &nbsp;&nbsp;
      &nbsp;&nbsp;&nbsp; # current_user may be undef too<br>
      <br>
      Hope this helps,<br>
      Seb.<br>
      <br>
      <br>
      <br>
      On 17/07/14 13:45, Enio Carboni wrote:<br>
    </div>
    <blockquote cite="mid:53C7C56B.1010405@gmail.com" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix">Hi John,<br>
        &nbsp;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>
        &nbsp; 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 moz-do-not-send="true" 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&#8217;t want to redirect from <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://repo/123/">http://repo/123/</a> to <a moz-do-not-send="true" 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 moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">eprints-tech-bounces@ecs.soton.ac.uk</a> [<a moz-do-not-send="true" 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 moz-do-not-send="true" 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 moz-do-not-send="true" 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 moz-do-not-send="true" 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 moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a>
*** EPrints community wiki: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://wiki.eprints.org/">http://wiki.eprints.org/</a>
*** EPrints developers Forum: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://forum.eprints.org/">http://forum.eprints.org/</a>
</pre>
        </blockquote>
        <pre wrap="">*** Options: <a moz-do-not-send="true" 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 moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a>
*** EPrints community wiki: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://wiki.eprints.org/">http://wiki.eprints.org/</a>
*** EPrints developers Forum: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://forum.eprints.org/">http://forum.eprints.org/</a>

*** Options: <a moz-do-not-send="true" 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 moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a>
*** EPrints community wiki: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://wiki.eprints.org/">http://wiki.eprints.org/</a>
*** EPrints developers Forum: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://forum.eprints.org/">http://forum.eprints.org/</a>
</pre>
      </blockquote>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <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>
</pre>
    </blockquote>
    <br>
  </body>
</html>