Open djay opened 8 years ago
I have used a different approach, but it is covered by https://github.com/plomino/rapido.core/commit/aa97d9e0b27bebc22dd1aea67b1231e060d4daef (see doc here: https://github.com/plomino/rapido.plone/blob/master/docs/python-api.rst#contextmodules)
It is easier to provide modules through context
. Using NamesChecker
is very painful with nested modules, like for instance allowing datetime.date.today
.
Re-open if necessary.
that way is just not scalable. You can't expect the core to be updated to allow access to every module that might exist? In addition I don't like having new apis for things that are well documented else where. It's counter intuitive to have the rest of the world saying "import plone.api" but in rapido world you have to read enough documentation to realise that this becomes "context.module.plone.api"? If the problem is making untrusted python easier to whitelist modules then thats the fix we need to explore IMO
I think I can create some utils to make it easier to whitelist but they probably shouldn't go in safelib (which is more a kitchensick of already whitelisted modules). Perhaps it should get added to untrustedpython itself?
I created an issue here https://github.com/zopefoundation/zope.untrustedpython/issues/1
I agree it would be semantically much better to be able to import modules.
But regarding:
that way is just not scalable. You can't expect the core to be updated to allow access to every module that might exist?
maybe the doc is unclear, but you can declare new safe modules from outside Rapido (for instance from a custom addon) like this:
import whatever
from rapido.core import app
app.safe_modules.whatever = whatever
I'll modify the docs but for now it works kind of like this
I suspect there are better ways but this works for now.
For classes this works