Plone 6 unable to recompile PythonScripts

Hints appreciated:

When starting Plone I see a message that advises me to recompile my stale PythonScripts:

2024-09-19 09:42:31,027 INFO [PythonScripts:218][waitress-0] Some of your Scripts have stale code cached. Since Zope cannot use this code, startup will be slightly slower until these Scripts are edited. You can automatically recompile all Scripts that have this problem by visiting /manage_addProduct/PythonScripts/recompile of your server in a browser.

When visiting the ZMI, it appears that this action is successful:

Screenshot from 2024-09-19 09-48-32

but the backend shows that due to CSRF protection it is not. Saving the files individually is a workaround that works.

2024-09-19 09:42:31,042 INFO    [plone.protect:283][waitress-0]   File "/usr/lib/python3.11/threading.py", line 1002, in _bootstrap
    self._bootstrap_inner()

  File "/usr/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()

  File "/usr/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)

  File "/usr/local/Plone6/lib/python3.11/site-packages/waitress/task.py", line 84, in handler_thread
    task.service()

  File "/usr/local/Plone6/lib/python3.11/site-packages/waitress/channel.py", line 428, in service
    task.service()

  File "/usr/local/Plone6/lib/python3.11/site-packages/waitress/task.py", line 168, in service
    self.execute()

  File "/usr/local/Plone6/lib/python3.11/site-packages/waitress/task.py", line 434, in execute
    app_iter = self.channel.server.application(environ, start_response)

  File "/usr/local/Plone6/lib/python3.11/site-packages/paste/translogger.py", line 77, in __call__
    return self.application(environ, replacement_start_response)

  File "/usr/local/Plone6/lib/python3.11/site-packages/ZPublisher/httpexceptions.py", line 30, in __call__
    return self.application(environ, start_response)

  File "/usr/local/Plone6/lib/python3.11/site-packages/ZPublisher/WSGIPublisher.py", line 389, in publish_module
    with transaction_pubevents(request, response):

  File "/usr/lib/python3.11/contextlib.py", line 144, in __exit__
    next(self.gen)

  File "/usr/local/Plone6/lib/python3.11/site-packages/ZPublisher/WSGIPublisher.py", line 183, in transaction_pubevents
    notify(pubevents.PubBeforeCommit(request))

  File "/usr/local/Plone6/lib/python3.11/site-packages/zope/event/__init__.py", line 33, in notify
    subscriber(event)

  File "/usr/local/Plone6/lib/python3.11/site-packages/zope/component/event.py", line 27, in dispatch
    component_subscribers(event, None)

  File "/usr/local/Plone6/lib/python3.11/site-packages/zope/component/_api.py", line 146, in subscribers
    return sitemanager.subscribers(objects, interface)

  File "/usr/local/Plone6/lib/python3.11/site-packages/zope/interface/registry.py", line 445, in subscribers
    return self.adapters.subscribers(objects, provided)

  File "/usr/local/Plone6/lib/python3.11/site-packages/zope/interface/adapter.py", line 896, in subscribers
    subscription(*objects)

  File "/usr/local/Plone6/lib/python3.11/site-packages/plone/transformchain/zpublisher.py", line 75, in applyTransformOnSuccess
    transformed = applyTransform(event.request)

  File "/usr/local/Plone6/lib/python3.11/site-packages/plone/transformchain/zpublisher.py", line 65, in applyTransform
    transformed = transformer(request, result, encoding)

  File "/usr/local/Plone6/lib/python3.11/site-packages/plone/transformchain/transformer.py", line 50, in __call__
    newResult = handler.transformIterable(result, encoding)

  File "/usr/local/Plone6/lib/python3.11/site-packages/plone/protect/auto.py", line 180, in transformIterable
    if not self.check():

  File "/usr/local/Plone6/lib/python3.11/site-packages/plone/protect/auto.py", line 205, in check
    return self._check()

  File "/usr/local/Plone6/lib/python3.11/site-packages/plone/protect/auto.py", line 286, in _check
    "\n".join(traceback.format_stack()), self.request.URL

aborting transaction due to no CSRF protection on url http://localhost:8888/Plone/manage_addProduct/PythonScripts/recompile

Or you could call this URL via Postman as POST request ...

1 Like

Nifty! Using the RESTer Firefox extension: