-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write layer-source of object into Data.FS #132
base: main
Are you sure you want to change the base?
Conversation
As long as the Python property Since the ZMI patch just does nothing on objects which do not have the property, it's also okay to just to incorporate a patch in So, I believe we should use this idea, unless @viktordick or @gandie have objections… |
No objections per se, though the mentioned missing update might be a bit difficult (this operation usually writes from the Data.FS into the file system, and would now require a response being written back) and without that this feature might sometimes give erroneous information. And implementing this would also break the assumption that a |
c427489
to
e90b02c
Compare
@viktordick I've added a "writing"-back of the zodbsync_layer to the Data.FS and a Test to prove it working correctly and clearing back to the custom layer if the file is there! But I'm not entirely sure about my latest commit. Somehow the usage of a Transaction to writeback the zodbsync_layer has broken the test |
@viktordick sorry, I think my test was just poorly written so the transaction usage in the record was totally not necessary and therfor the fix on the test was also not required. Basically ignore the whole part of the last message about this topic |
@@ -162,6 +164,9 @@ def mod_write(data, parent=None, obj_id=None, override=False, root=None, | |||
for handler in mod_implemented_handlers(obj, meta_type): | |||
handler.write(obj, d) | |||
|
|||
# Also write zodbsync layer information | |||
obj.zodbsync_layer = layer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this will have no effect on most record
runs since they don't commit their transaction. In particular, the watch
command explicitly aborts its transaction (https://github.com/perfact/zodbsync/blob/main/perfact/zodbsync/commands/watch.py#L357) since it is used to only make sure a consistent state is viewed and it does not expect that anything is changed in the Data.FS. And a regular record
run uses an implicit transaction that is neither commited nor aborted, which I am pretty sure means an implicit abort.
Well, does what is says on the tin (atleast proof of concept wise)! Basically I had the idea that the Data.FS should just know from which layer an object was uploaded so we can make use of this information inside of the application (for example the ZMI). For this we just store the layer-ident in the
zodbsync_layer
property of an object (not the PropertySheet functionality, but just actual python properties), which are just as happily written into the Data.FS!Whats currently missing is the "update" of this property in case the file is changed in Zope and therefor changes it`s source-layer! But I wanted to wait to implement something for this until I got feedback on whether this is actually something we would like to pursue further.
For testing purposes I actually patched the ZMI to display the layer-ident, which is really working like a charm: