I am trying to customize a ploneformgen form by dynamically populating a selection field. I need to parse a file on my filesystem and select certain options based on their date and time. Creating the python script was no brainer but then where do I place the script?
- From what I understand, external methods are not the preferred choice in plone 4
- I tried to add a python script via ZMI but then I was hit by restricted python and my script would not execute.
- I developed an add-on and placed it in the eggs folder and then wrote a python script to call the code from the add-on but unfortunately I was hit again with the same error as previously "You do not have sufficient permissions to view this page". From what I understood, code inside an add-on is not restricted, or?
What would be the best option to achieve the customisation of the form?
If you used a skin script, then yes, that is run as restricted python as well. It is the filesystem-stored equivalent of the ZMI python script.
Best practice is to use a browser view; it is simply a callable object that has a request and context associated to it:
Register this in your configure.zcml:
after which it'll be available as
someobject/@@mybrowserview
for PloneFormGen.However, if this is the only thing you are creating a custom package for then by all means use an external method.