A readonly wrapper around a ZODB storage
Project description
Readonly Storage
A simple read-only wrapper around a regular ZODB storage.
import ZODB
# Let's set a read-write DemoStorage
rw_storage = ZODB.DemoStorage.DemoStorage()
rw_db = ZODB.DB(rw_storage)
# And now, let's set a ReadOnlyStorage around it.
ro_storage = readonlystorage.ReadOnlyStorage(rw_storage)
ro_db = ZODB.DB(ro_storage)
# Now, add some data
rw_conn = rw_db.open()
rw_conn.root()["foo"] = "bar"
rw_conn.transaction_manager.commit()
rw_conn.close()
# Read the data
ro_conn = ro_db.open()
assert "bar" == ro_conn.root()["foo"]
ro_conn.root()["foo"] = "anything"
ro_conn.transaction_manager.commit() # This one would emit a ZODB.POSException.ReadOnlyError!
ro_conn.close()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
readonlystorage-0.0.1.tar.gz
(2.2 kB
view hashes)
Built Distribution
Close
Hashes for readonlystorage-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be17559b582d0477bf75204edab90da22057ce80dab0133b067680be454d8f8e |
|
MD5 | 5aae3c29378d043c636137967f61e2b3 |
|
BLAKE2b-256 | 649b8d5543197190dbf85fb9086425c66555f0bf097bb028714f8db4f000607d |