summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-08-11 18:07:02 -0700
committerBob Halley <halley@dnspython.org>2020-08-11 18:07:02 -0700
commit6cf5fa8b4c271515caca9318ac471197b28fc619 (patch)
treed1b07c9927e162be33cf14870fe4cf7d9559ccf2 /doc
parentd6a5f4f0e8004d09864cd96c243287b837204547 (diff)
downloaddnspython-6cf5fa8b4c271515caca9318ac471197b28fc619.tar.gz
doco update
Diffstat (limited to 'doc')
-rw-r--r--doc/whatsnew.rst2
-rw-r--r--doc/zone-class.rst69
2 files changed, 70 insertions, 1 deletions
diff --git a/doc/whatsnew.rst b/doc/whatsnew.rst
index 8ff267c..b6090b9 100644
--- a/doc/whatsnew.rst
+++ b/doc/whatsnew.rst
@@ -25,7 +25,7 @@ What's New in dnspython
* The SVCB and HTTPS RR types are now supported.
* TSIG has been enhanced with TKEY and GSS-TSIG support. Thanks to
-Nick Hall for writing this.
+ Nick Hall for writing this.
2.0.0
-----
diff --git a/doc/zone-class.rst b/doc/zone-class.rst
index b4d9869..bdaf884 100644
--- a/doc/zone-class.rst
+++ b/doc/zone-class.rst
@@ -3,6 +3,11 @@
The dns.zone.Zone Class
-----------------------
+The ``Zone`` class provides a non-thread-safe implementation of a DNS zone,
+as well as a lightweight transation mechanism that allows it to be atomically
+updated. For more complicated transactional needs, or for concurrency, please
+use the ``dns.versioned.Zone`` class (described below).
+
.. autoclass:: dns.zone.Zone
:members:
@@ -28,3 +33,67 @@ create new nodes and defaults to ``dns.node.Node``. ``Zone`` may be
subclassed if a different node factory is desired.
The node factory is a class or callable that returns a subclass of
``dns.node.Node``.
+
+
+The dns.versioned.Zone Class
+----------------------------
+
+A versioned Zone is a subclass of ``Zone`` that provides a thread-safe
+multiversioned transactional API. There can be many concurrent
+readers, of possibly different versions, and at most one active
+writer. Others cannot see the changes being made by the writer until
+it commits. Versions are immutable once committed.
+
+The read-only parts of the standard zone API continue to be available, and
+are equivalent to doing a single-query read-only transaction. Note that
+unless reading is done through a transaction, version stability is not
+guaranteed between successive calls. Attempts to use zone API methods
+that directly manipulate the zone, e.g. ``replace_rdataset`` will result
+in a ``UseTransaction`` exception.
+
+Transactions are context managers, and are created with ``reader()`` or
+``writer()``. For example:
+
+::
+
+ # Print the SOA serial number of the most recent version
+ with zone.reader() as txn:
+ rdataset = txn.get('@', 'in', 'soa')
+ print('The most recent serial number is', rdataset[0].serial)
+
+ # Write an A RR and increment the SOA serial number to the next value.
+ with zone.writer() as txn:
+ txn.replace('node1', dns.rdataset.from_text('in', 'a', 300,
+ '10.0.0.1'))
+ txn.set_serial()
+
+See below for more information on the ``Transaction`` API.
+
+.. autoclass:: dns.versioned.Zone
+ :exclude-members: delete_node, delete_rdataset, replace_rdataset
+ :members:
+
+ .. attribute:: rdclass
+
+ The zone's rdata class, an ``int``; the default is class IN.
+
+ .. attribute:: origin
+
+ The origin of the zone, a ``dns.name.Name``.
+
+ .. attribute:: nodes
+
+ A dictionary mapping the names of nodes in the zone to the nodes
+ themselves.
+
+ .. attribute:: relativize
+
+ A ``bool``, which is ``True`` if names in the zone should be relativized.
+
+
+The Transaction Class
+---------------------
+
+.. autoclass:: dns.transaction.Transaction
+ :members:
+