Programmatically changing the proxy property of Python Scripts


A couple of years ago I adapted a very old product from Tres Seaver, FSDump, to export app objects from a Z2 app to a Z4 instance (export/export didn't work).

Now, I would like to further adapt it to send ZODB app objects to a git repo (app was not converted to install from the file system).

One issue remains for my needs. I can't load the proxy property of a Python script. I'm dumping it like this (don't remember why I used aq_base):

        if getattr(obj.aq_base, '_proxy_roles', None):
            file.write('proxy=%s\n' % ','.join(obj._proxy_roles))

To load, this doesn't work:

        if 'proxy' in props:
            proxy = props.pop('proxy')
            obj._proxy_roles = tuple(proxy.split(','))

The revised Zope Product is here: GitHub - ghiodor/Products.FSDump4 at load

I browsed Zope code but couldn't find a way to do it. Can you help please?

Why not?
It should work (you call commit after the change?).

When you change the proxy roles via the ZMI, then the script's mange_proxy it called. This essentially sets _proxy_roles. Thus if you can change proxy roles via the ZMI, you should be able to change them programmatically.

try to print

maybe it is not a tuple, but is an iterator so join on it works?

Nothing happens, no change.

Strange, I don't recall seeing this commit method, can you clarify?

I need to call obj.commit()?

Thanks, will research Zope source of course if needed.

Thanks for the tip, I didn't consider this before!
I was rather thinking it was a matter of needing to use a specific Zope API or security requirement.

Plone Foundation Code of Conduct