Open nils opened 3 years ago
Hi @jackw01, could you provide some feedback on this?
Any chances to get it merged? If not, I'd be happy to learn why :-)
I understand the motivation for having this feature to be able to use classes, helper functions, and global variables in patterns, but I would rather it be implemented using RestrictedPython instead of using the unsafe compile
and executing the pattern with access to all existing global variables. If I were to implement this, I would allow each pattern to have a separate setup
function that gets called once after the code is compiled to set up any classes or global variables that can then be used by the pattern
function. I am not sure about the exact implementation details for this, but I will look into it when I have some free time.
The one use case I can see that this approach wouldn't cover is being able to read data from a file from within animation code, which could be solved by adding a command line flag like you have that would (unsafely) add open
and other file-related functionality to the list of allowed globals.
Hi @jackw01,
I'd like to write complex patterns with classes and everything Python provides, so this PR proposes a new command line flag
--run-unsafe
which does run the pattern code in an unrestricted way.However, I have to admit that I'm not very experienced with Python, so I'd welcome every feedback you have concerning the code quality.
Best Regards, Nils