Jump to content
Wiki Home
EPrints Home
Bazaar
Files
Main menu
Main menu
move to sidebar
hide
Navigation
Front Page
EPrints 3 Manual
EPrints Training Course
EPrints Glossary
Installing EPrints
How-to Configure EPrints
EPrints 3.2+ API
EPrints 3 Reference
EPrints Plugins
Wiki
All categories
Recent changes
Main Page
Help
EPrints Documentation
Search
Search
Appearance
Log in
Request account
Personal tools
Log in
Request account
Pages for logged out editors
learn more
Contributions
Talk
Editing
Anatomy of a request
(section)
Page
Discussion
British English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===EPrint IDs, Documents and EP_TRIGGER_DOC_URL_REWRITE=== [https://github.com/eprints/eprints/blob/88a36fcf1f17c7a04e60455d374b617709f7461d/perl_lib/EPrints/Apache/Rewrite.pm#L377-493 Lines 377-493] This block of code looks for requests starting with e.g. <code><nowiki>http://repository.blah/123</nowiki></code> - where '123' is an EPrintID. There are some <code>redir</code>ects in this block to account for older URL that may be requested that had EPrintIDs and/or document positions zero-padded <code><nowiki>http://repository.blah/00000123</nowiki></code> or <code><nowiki>http://repository.blah/00000123/01/Document.txt</nowiki></code>. Each subsequent match on the <code>$uri</code> consumes part of it - e.g. [https://github.com/eprints/eprints/blob/88a36fcf1f17c7a04e60455d374b617709f7461d/perl_lib/EPrints/Apache/Rewrite.pm#L377 Line 377] <source lang="perl">$uri =~ s! ^$urlpath/(0*)([1-9][0-9]*)\b !!x</source> will remove the EPrintID from the start of <code>$uri</code>. [https://github.com/eprints/eprints/blob/88a36fcf1f17c7a04e60455d374b617709f7461d/perl_lib/EPrints/Apache/Rewrite.pm#L398-467 Lines 398-467] deal with document requests. [https://github.com/eprints/eprints/blob/88a36fcf1f17c7a04e60455d374b617709f7461d/perl_lib/EPrints/Apache/Rewrite.pm#L398 Line 398] <source lang="perl">$uri =~ s! ^/(0*)([1-9][0-9]*)\b !!x</source> will match elements '''after''' the EPrintID in the original URL - matching '45' in *<code><nowiki>http://repository.blah/123/45/Document.txt</nowiki></code> or *<code><nowiki>http://repository.blah/123/45.hassmallThumbnailVersion/Document.txt</nowiki></code> (the second example shows the use of a 'relationship' that is processed using a EP_TRIGGER_DOC_URL_REWRITE trigger). [https://github.com/eprints/eprints/blob/88a36fcf1f17c7a04e60455d374b617709f7461d/perl_lib/EPrints/Apache/Rewrite.pm#L418-419 Lines 418-419] may be a bit confusing at first glance. <source lang="perl"> $uri =~ s! ^([^/]*)/ !!x; my @relations = grep { length($_) } split /\./, $1; </source> They deal with document relationships - that are of the form <code>.../DocID.relationship1.relationship2.relationshipN/...</code>. For documents, thumbnails are presented as related documents, the relationship is e.g. 'hassmallThumbnailVersion'. The first line gets anything from the start of <code>$uri</code> (the DocID already having been removed by line 398), to the next '/'. The second line (possibly the least readable line of code in EPrints?): *takes the captured match ($1): <code>.relationship1.relationship2.relationshipN</code> *splits on '.'s: <code>"","relationship1","relationship2","relationshipN"</code> *for each of the split values (referenced as $_): grep for the length of the value. This effectively strips out empty elements (length = 0, grep doesn't return the value). *@relationships = <code>"relationship1","relationship2","relationshipN"</code> [https://github.com/eprints/eprints/blob/88a36fcf1f17c7a04e60455d374b617709f7461d/perl_lib/EPrints/Apache/Rewrite.pm#L421 Line 421] then assigns whatever is left of the URL as the filename. [https://github.com/eprints/eprints/blob/88a36fcf1f17c7a04e60455d374b617709f7461d/perl_lib/EPrints/Apache/Rewrite.pm#L423-426 Lines 423-426] use 'pnotes' (http://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.html#C_pnotes_) to pass objects to the request handler. [https://github.com/eprints/eprints/blob/88a36fcf1f17c7a04e60455d374b617709f7461d/perl_lib/EPrints/Apache/Rewrite.pm#L433-436 Lines 433-436] call document specific authen and authz methods. These deal with the 'security' flag on the document, and are part of the core EPrints that needs to be addressed with ACL. <source lang="perl"> $r->push_handlers(PerlAccessHandler => [ \&EPrints::Apache::Auth::authen_doc, \&EPrints::Apache::Auth::authz_doc ] ); </source> [https://github.com/eprints/eprints/blob/88a36fcf1f17c7a04e60455d374b617709f7461d/perl_lib/EPrints/Apache/Rewrite.pm#L440 Line 440] add the document-download log handler to the request cleanup phase: <source lang="perl">$r->pool->cleanup_register(\&EPrints::Apache::LogHandler::document, $r);</source> [https://github.com/eprints/eprints/blob/88a36fcf1f17c7a04e60455d374b617709f7461d/perl_lib/EPrints/Apache/Rewrite.pm#L443-459 Lines 443-458] call the EP_TRIGGER_DOC_URL_REWRITE triggers. There is one default trigger for this - in <code>~/lib/cfg.d/doc_rewrite.pl</code> that handles the relationship-based document requests. [https://github.com/eprints/eprints/blob/88a36fcf1f17c7a04e60455d374b617709f7461d/perl_lib/EPrints/Apache/Rewrite.pm#L470-490 Lines 470-490] If the URL has an EPrint, but doesn't have a document, we reach this block - which updates the abstract page if necessary, and uses the EPrints templating system to render the page. It also logs the page view using <code>EPrints::Apache::LogHandler::eprint</code>.
Summary:
Please note that all contributions to EPrints Documentation may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
EPrints Documentation:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)