Comments (5)
I don't think this hurts non-RelStorage storages, because this happens at a level below the adapter.
By RelStorage+zlibstorage, do you mean zlibstorage wrapping RelStoage? Because it copies interfaces, it's claiming to implement IMVCCStorage, but isn't. Perhaps it should implement new_instance.
I don't see off hand how adding new_instance to CRS would help.
FTR, I'd really like to conflict resolution out of the storage layer. If it was done by ZODB itself, we could lose this silly transformation dance and simplify storage implementations. Potentially, we could improve conflict resolution quite a bit as well. FWIW: https://github.com/zopefoundation/ZODB/wiki/OO-conflict-resolution
from zodb.
By RelStorage+zlibstorage, do you mean zlibstorage wrapping RelStoage?
Yes.
Because it copies interfaces, it's claiming to implement IMVCCStorage, but isn't. Perhaps it should implement new_instance.
I have a bug open for that, although that's not quite enough.
I don't see off hand how adding new_instance to CRS would help.
CRS sets some attributes in registerDB
. When zc.zlibstorage wraps a CRS, those attributes are necessary for conflict resolution to work. registerDB
is only called once when a DB is constructed, on the root storage. Each time new_instance
is called, a brand new object is created and returned. And because CRS doesn't implement new_instance
, those attributes are not set on the new instance. So the new instance is effectively broken; instead of using the transformation attributes set by registerDB
, it uses the default class-level transformation attributes.
The proposal here is that CRS.new_instance()
should set on the new instance the same attributes that were set in registerDB
.
from zodb.
What would call CRS.new_instance? CRS is a mix-in class.
Through the magic of the getattr hack, when new_instance is called on a zlibstorage, RelStorage's new_instance would be called. Would it then call CRS' new_instance? new_instance doesn't have the right semantics here, as it, you know, creates new instances. If RelStorage's new_instance called CRS's new_instance, it would get a new instance from CRS, when all it wants is to copy some attributes. This feels like the wrong model here.
If you really want to fix this, a better way IMO would be for zlibstorage to implement a new_instance that delegates to the base and then calls registerDB on the result.
(Of course, new_instance, implying cloning is a questionable model to begin with.)
Finally, this is a terrible place to discuss things. I'd strongly prefer IRC or some other real-time chat for this.
from zodb.
I would probably implement it like this in CRS:
def _new_instance(self):
# subclass-specific work done here
raise AttributeError("new-instance")
def new_instance(self):
instance = self._new_instance()
instance._crs_untransform_record_data = self._crs_untransform_record_data
instance._crs_transform_record_data = self._crs_transform_record_data
return instance
Then in RelStorage I would always define _new_instance
and only conditionally define new_instance
(to look exactly like what's above) depending on whether CRS already had a definition or not.
from zodb.
This is too convoluted. Inheritance is a terrible way to provide an API. This is a RelStorage-specific problem that's easy to solve in RelStorage. Just copy those two attributes in RelStorage's new_instance and be done with it.
from zodb.
Related Issues (20)
- Is ZODB unmaintained? HOT 2
- Connecting to ClientStorage using a Windows machine HOT 4
- fsoids script fails reporting the shortened tid description on Python 3
- DeprecationWarning in Python 3.10
- `fsstats` no longer matches output of `fsdump`
- Change `pack_date` interpretation?
- Any objections to releasing 5.7.0? HOT 3
- Blob usage depending on file size HOT 4
- 5.7.0: missing git tag? HOT 2
- 5.7.0: documentation build fails with sphinx 5.x HOT 11
- 5.7.0: pytest warning and ZODB/tests should not be installed HOT 13
- PyInstaller fails to find ZODB's config.xml and exe will no run when using a provided config from URL HOT 2
- Incorporating Blob with ClientStorage HOT 8
- Dual Inquiry: 2022 Best Practices for ZODB usage outside of ZOPE using ZEO SharedStorage HOT 1
- FileStorage and other api doesn't support pathlib interface. HOT 1
- with transaction() doesn't work as expected
- On ZODB's scalability HOT 6
- [Question] documentation for contributor of ZODB ecosystem HOT 1
- Switch test name prefix from `check` to `test`. HOT 2
- ZODB with nogil Python HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zodb.