EPrints Technical Mailing List Archive
Message: #09471
< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First
RE: [EP-tech] ORCID Plugin Subroutine run_people_with_orcids redefined
- To: "eprints-tech@ecs.soton.ac.uk" <eprints-tech@ecs.soton.ac.uk>
- Subject: RE: [EP-tech] ORCID Plugin Subroutine run_people_with_orcids redefined
- From: John Salter <J.Salter@leeds.ac.uk>
- Date: Fri, 3 Nov 2023 12:12:06 +0000
CAUTION: This e-mail originated outside the University of Southampton. Hi Yuri, Sorry - long email - but hopefully useful for you and others - especially when creating extensions to EPrints! There's a difference between things that are already expecting a config function to exist (like validate_eprint), and adding a new function to a core EPrints module. If you need to add a method to e.g. the EPrints::DataObj::User module (so you can do $user->something_very_specific( ... ); )then writing into another package is needed. Your point is still valid - when adding a method to an existing module, it should be considered whether the function should refer to an archive-level config - rather than being hard-coded. To add a method to one of the core modules, the best way to do it is to create a module that will go in lib/plugins or site_lib/plugins - and then write into the other package e.g. - https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdimensions-badge%2Fblob%2F67be1fe9a40ac3681e44fe09fbfc2bb6a0b43ec1%2Flib%2Fplugins%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FBox%2FDimensionsBadge.pm%23L132&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C24a7b387924f4d1593de08dbdc661a6b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638346103319551029%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ck%2BHjeeo0JmCftUnbrTFj53Mtx2Kzg7Qv%2Fj%2FgOQACxU%3D&reserved=0 - https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fyoutube_import%2Fblob%2Ffdd916050bc47099fc44351976b1987443d1fef2%2Flib%2Fplugins%2FEPrints%2FPlugin%2FImport%2FYoutube.pm%23L406&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C24a7b387924f4d1593de08dbdc661a6b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638346103319551029%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gleAIKvGkGRMndd%2FpnR4raGGVvaC9WiZRmDcfTDhIVQ%3D&reserved=0 This works best when there are multiple archives running under one instance of EPrints - as the code is only added once. There are quite a few plugins that add methods to core modules via cfg.d/x.pl files e.g. - https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fcarousel%2Fblob%2F7c730ffd5bb5e893dee507d5191098440df2bff5%2Flib%2Fcfg.d%2Fcarousel.pl%23L34&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C24a7b387924f4d1593de08dbdc661a6b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638346103319551029%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=eW%2Bg64%2FWeP2H7dDRQrz6qAZocbjdyxQGJgNidYP7iII%3D&reserved=0 - https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdorian%2Fblob%2F84ba3f204be218e0b56b79e6e96bdbff67e5211a%2Flib%2Fcfg.d%2Fzz_dorian.pl%23L71&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C24a7b387924f4d1593de08dbdc661a6b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638346103319551029%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=xAY3idk38AHNUgvAWw6X%2FkM7eFFC9FI9snCgfi9T7Hk%3D&reserved=0 Often this is done to make deployment feel easier - e.g. everything is in one file, but this may point to the extension not having been fully tested in a multi-archive setup. If it is tested in a multi-archive setup, you may see a 'no warnings wq(redefine);' line in the .pl file - to suppress the warnings. This is just hiding the issue, and can make troubleshooting harder. I've been there! In the 'DimensionsBadge' I tried to make the right balance. Some things are called from a cfg.d defined function. These are things that are likely to need local customisation for different archives. https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdimensions-badge%2Fblob%2Fmaster%2Flib%2Fplugins%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FBox%2FDimensionsBadge.pm%23L67-L72&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C24a7b387924f4d1593de08dbdc661a6b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638346103319707305%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=JhGN2uMrFmQuHpy2%2B7Ujy%2BEn7OVxJjq6UdeDviBSU18%3D&reserved=0 Other things can be set via the EPrints Plugin parameters, but these have useful defaults, and are less likely to need to be used (but are still documented): https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdimensions-badge%2Fblob%2Fmaster%2Flib%2Fplugins%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FBox%2FDimensionsBadge.pm%23L101-L111&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C24a7b387924f4d1593de08dbdc661a6b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638346103319707305%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=eFsmZ7X8SBYV2uV%2FXXDomtfKTpoSJgNM9%2BBymXJsxnc%3D&reserved=0 and https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdimensions-badge%2Fblob%2Fmaster%2Fcfg%2Fcfg.d%2Fz_dimensions_badge.pl%23L74-L84&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C24a7b387924f4d1593de08dbdc661a6b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638346103319707305%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=LDnjjFQ8rjZcYTLRwRJCyIfG2mhCF4ORkgRbjZz8Gz4%3D&reserved=0 Hope that makes sense. If you (or anyone) creating extensions for EPrints would like other people to review the structure/code, I'm sure asking people on here will get some interest. Cheers, John -----Original Message----- From: eprints-tech-request@ecs.soton.ac.uk <eprints-tech-request@ecs.soton.ac.uk> On Behalf Of Yuri Sent: Thursday, November 2, 2023 11:46 AM To: eprints-tech@ecs.soton.ac.uk Subject: Re: [EP-tech] ORCID Plugin Subroutine run_people_with_orcids redefined CAUTION: This e-mail originated outside the University of Southampton. CAUTION: This e-mail originated outside the University of Southampton. What is the porpouse of adding a method to an existing package from a cfg.d file? Isnt' better to use a config that points to the function, so archive can overwrite customizable functions? Like we do already with eprints/lib/defaultcfg/cfg.d/eprint_validate.pl($c->{validate_eprint} = sub ...). Il 01/11/23 14:19, John Salter ha scritto: > the config in z_orcid_support.pl > (https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit%2F&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C24a7b387924f4d1593de08dbdc661a6b%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C638346103319707305%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=eht1jIHsUf1o94ZATA5VSNzh81FlLMdomAZCob3FuEM%3D&reserved=0 > hub.com%2Feprints%2Forcid_support%2Fblob%2Fmaster%2Fcfg%2Fcfg.d%2Fz_or > cid_support.pl%23L124-L130&data=05%7C01%7Cj.salter%40leeds.ac.uk%7C7be > 9a59119a34437658108dbdb99650c%7Cbdeaeda8c81d45ce863e5232a535b7cb%7C0%7 > C0%7C638345224090257371%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLC > JQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=8PS > B6cmVZI75IaiUtLCBsG38jASUmi9VTbjRpY2jr30%3D&reserved=0 > ) is adding a new method to the EPrints::Script::Compiled package. For > archive 'aaa', this is OK. For archive 'bbb' (and each one > alphabetically after it), it will be redefining the method - and the > warning is produced.
- References:
- [EP-tech] ORCID Plugin Subroutine run_people_with_orcids redefined
- From: "Beaudoin, Mario" <Mario.Beaudoin@uqtr.ca>
- RE: [EP-tech] ORCID Plugin Subroutine run_people_with_orcids redefined
- From: John Salter <J.Salter@leeds.ac.uk>
- Re: [EP-tech] ORCID Plugin Subroutine run_people_with_orcids redefined
- From: Yuri <yurj@alfa.it>
- [EP-tech] ORCID Plugin Subroutine run_people_with_orcids redefined
- Prev by Date: RE: [EP-tech] ORCID Plugin Subroutine run_people_with_orcids redefined
- Next by Date: [EP-tech] OAI2 can not display List Records because XML Parsing Error: duplicate attribute
- Previous by thread: Re: [EP-tech] ORCID Plugin Subroutine run_people_with_orcids redefined
- Next by thread: RE: [EP-tech] ORCID Plugin Subroutine run_people_with_orcids redefined
- Index(es):