Skip to content

Commit f02ba03

Browse files
jensensstevepiercy
andauthored
ZODB chapter (#1894)
* ZODB chapter draft (cherry picked from commit 07e6920c9c465e04e20cafd39f2034e85605224a) * - Convert bullet list to definition list to improve readability and identify terms. - Enhance and add glossary terms. - Name the item before using its acronym. - Fix typos and grammar. --------- Co-authored-by: Steve Piercy <web@stevepiercy.com>
1 parent 1aa1bd2 commit f02ba03

File tree

2 files changed

+77
-5
lines changed

2 files changed

+77
-5
lines changed

docs/backend/zodb.md

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,76 @@
11
---
22
myst:
33
html_meta:
4-
"description": ""
5-
"property=og:description": ""
6-
"property=og:title": ""
7-
"keywords": ""
4+
"description": "Zope Object Database (ZODB)"
5+
"property=og:description": "Zope Object Database (ZODB)"
6+
"property=og:title": "Zope Object Database (ZODB)"
7+
"keywords": "Plone, ZODB, Zope Object Database, RelStorage, ZEO, ZODB Extension Objects"
88
---
99

10+
% TODO: Diátaxis conceptual guide
11+
1012
(backend-zodb-label)=
1113

12-
# ZODB
14+
# Zope Object Database (ZODB)
15+
16+
The {term}`Zope Object Database` (ZODB) is a Python native, object-oriented database designed for direct persistence of Python objects.
17+
Unlike traditional relational databases that rely on tables and SQL queries, ZODB allows developers to work directly with Python objects, persisting them without the need for object-relational mapping (ORM).
18+
19+
20+
## Core features of ZODB
21+
22+
Transparent persistence
23+
: Objects stored in ZODB automatically persist.
24+
In a Plone request/response cycle, they do not require an explicit save or commit operation, since this is done automatically.
25+
26+
No schema constraints
27+
: Unlike relational databases, ZODB does not require predefined schemas, allowing for flexible and dynamic data structures.
28+
The attributes of the Python objects themselves are stored.
29+
30+
ACID compliance
31+
: ZODB ensures data consistency through transactions that support atomicity, consistency, isolation, and durability (ACID).
32+
33+
Automatic conflict resolution
34+
: With its multi-version concurrency control (MVCC), ZODB can handle concurrent access efficiently.
35+
36+
Built-in versioning and undo
37+
: The database allows versioning, enabling rollback to previous states if needed.
38+
39+
Scalability
40+
: ZODB can be used in standalone applications or scaled with {term}`ZODB Extension Objects` (ZEO) for distributed storage.
41+
Additionally, ZODB supports the {term}`RelStorage` adapter, which allows it to use relational databases, including PostgreSQL, MySQL, or Oracle, as a backend, providing flexibility for integration with existing database infrastructures.
42+
43+
44+
## How ZODB works
45+
46+
At its core, ZODB operates as an object store, maintaining serialized Python objects with some metadata in a hierarchical structure.
47+
48+
Storage
49+
: Handles how objects are stored on disk or in-memory.
50+
51+
The default storage is {term}`FileStorage`, which writes data to `.fs` files. `FileStorage` does not scale, as only one process can work with it.
52+
53+
{term}`ZEO` storage is used for distributed multi-client access to the same database, introducing scalability.
54+
55+
{term}`RelStorage` is another highly scalable option.
56+
It allows ZODB to use relational databases like PostgreSQL, MySQL, or Oracle as backend storage, combining object persistence with traditional database infrastructure.
57+
RelStorage is used often in a containerized deployment environment.
58+
59+
Connection
60+
: Acts as the interface between Python applications and the database.
61+
With ZEO for each active Zope thread, one connection is established.
62+
Connections are pooled and re-used.
63+
64+
Transaction manager
65+
: Manages transactional operations, ensuring data integrity.
66+
A transaction normally starts with the request, and ends with the response.
67+
However, in long-running requests with lots of database writes, transactions can be committed in between.
68+
69+
Indexing and caching
70+
: Optimizes read and write operations for better performance.
71+
Tuning the ZODB cache sizes to hardware environment and the kind of data stored may help to speed up the application.
72+
73+
74+
## Further reading
1375

76+
More information can be found at the official [ZODB website](https://zodb.org/en/latest/).

docs/glossary.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,12 +554,21 @@ react-intl
554554
WSGI
555555
The Web Server Gateway Interface (WSGI, pronounced _WIZ-ghee_) is a simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language.
556556
557+
ZODB Extension Objects
557558
ZEO
558559
[ZEO](https://zeo.readthedocs.io/en/latest/) is a client-server storage for ZODB for sharing a single storage among many clients.
559560
561+
Zope Object Database
560562
ZODB
561563
[A native object database for Python](https://zodb.org/en/latest/).
562564
565+
`FileStorage`
566+
`FileStorage` is a Python class in {term}`ZODB` that saves data in a file.
567+
568+
```{seealso}
569+
https://zodb.org/en/latest/reference/storages.html#filestorage
570+
```
571+
563572
Zope
564573
[Zope](https://zope.readthedocs.io/en/latest/) is a Python-based application server for building secure and highly scalable web applications.
565574

0 commit comments

Comments
 (0)