What I really mean is that URL Services are always executed using a ServicePolicy that will not allow to execute bundled libraries. But I’ve found myself in need of using one, to run some Javascript on the page. It’s being included from the Shared Code, so it works just fine in the channel code, but not from the URL Service, even though it actually calls the same Shared Code and doesn’t try to use the external library directly.
So what now, do I dump my URL Service altogether or anybody knows of any workarounds?
@Twoure, thanks for the info! Looks like I’m already using the 1st method to import Shared Libraries that I have added as git submodules (to save me from figuring out how to “install” them into the channels properly and easier updates in the future), but it just didn’t occur to me that I could hack my way like this with the Shared Libraries themselves
And I’m using Js2Py by the way. Works very well to get the media URLs in cases when the website devs try to deter RegExers with obfuscated JavaScript.
But generally speaking, what was the reason for using Framework.policies.ServicePolicy for all URL Services? As far as I can tell from the Framework source code, there is a separate sandbox for each Service. Why not run them with the same policy as the channel they belong to? What we have now are the URL Services that are able to use Shared Code, that’s been introduced just for this reason (again, if my understanding is correct), to share the logic between Channel and URL Service, but as soon as I add Shared Libraries to my channel, the Shared Code effectively cannot be shared anymore, since it wouldn’t work in URL Service.
IIRC the Core functions are not available within the ServiceCode, because the service code runs within it’s own separate sandbox and doesn’t know what Core your referring.
To clarify, content from Contents/Code/ accessing the Contents/Services/Shared Code files will have access to the Core functions, but content from Contents/Services/URL/ accessing the Contents/Services/Shared Code files will not.
@Twoure, hm, I was sure I’ve put that to a Shared Code that was supposed to be called from a URL service, although that wasn’t my channel so I may be missing something, gotta check…