/usr/share/doc/python-sqlobject-doc/Versioning.html is in python-sqlobject-doc 3.1.0+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | <?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" />
<title></title>
<meta name="author" content="David Turner, The Open Planning Project" />
<link rel="stylesheet" href="default.css" type="text/css" />
</head>
<body>
<div class="document">
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author:</th>
<td>David Turner, The Open Planning Project</td></tr>
</tbody>
</table>
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#versioning" id="id2">Versioning</a><ul>
<li><a class="reference internal" href="#why" id="id3">Why</a></li>
<li><a class="reference internal" href="#how" id="id4">How</a></li>
<li><a class="reference internal" href="#inheritance" id="id5">Inheritance</a></li>
<li><a class="reference internal" href="#version-tables" id="id6">Version Tables</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="versioning">
<h1>Versioning</h1>
<div class="section" id="why">
<h2>Why</h2>
<p>You have a table where rows can be altered, such as a table of wiki
pages. You want to retain a history of changes for auditing, backup,
or tracking purposes.</p>
<p>You could write a decorator that stores old versions and manage all
access to this object through it. Or you could take advantage of the
event system in SQLObject 0.8+ and just catch row accesses to the
object. SQLObject's versioning module does this for you. And it even
works with inheritance!</p>
</div>
<div class="section" id="how">
<h2>How</h2>
<p>Here's how to set it up:</p>
<pre class="literal-block">
class MyClass(SQLObject):
name = StringCol()
versions = Versioning()
</pre>
<p>To use it, just create an instance as usual:</p>
<pre class="literal-block">
mc = MyClass(name='fleem')
</pre>
<p>Then make some changes and check out the results:</p>
<pre class="literal-block">
mc.set(name='morx')
assert mc.versions[0].name == 'fleem'
</pre>
<p>You can also restore to a previous version:</p>
<pre class="literal-block">
mc.versions[0].restore()
assert mc.name == "fleem"
</pre>
</div>
<div class="section" id="inheritance">
<h2>Inheritance</h2>
<p>There are three ways versioning can be used with <a class="reference external" href="Inheritance.html">inheritance</a>:</p>
<ol class="arabic">
<li><p class="first">Parent versioned, children unversioned:</p>
<pre class="literal-block">
class Base(InheritableSQLObject):
name = StringCol()
versions = Versioning()
class Child(Base):
toy = StringCol()
</pre>
</li>
</ol>
<p>In this case, when changes are made to an instance of Base, new
versions are created. But when changes are made to an instance of
Child, no new versions are created.</p>
<ol class="arabic simple" start="2">
<li>Children versioned, parents unversioned.</li>
</ol>
<p>In this case, when changes are made to an instance of Child, new
versions are created. But when changes are made to an instance of
Base, no new versions are created. The version data for Child
contains all of the columns from child and from base, so that a full
restore is possible.</p>
<ol class="arabic simple" start="3">
<li>Both children and parents versioned.</li>
</ol>
<p>In this case, changes to either Child or Base instances create new
versions, but in different tables. Child versions still contain all
Base data, and a change to a Child only creates a new Child version, not
a new Base version.</p>
</div>
<div class="section" id="version-tables">
<h2>Version Tables</h2>
<p>Versions are stored in a special table which is created when the table
for a versioned class is created. Version tables are not altered when
the main table is altered, so if you add a column to your main class,
you will need to manually add the column to your version table.</p>
</div>
</div>
</div>
<div class="footer">
<hr class="footer" />
Get SQLObject at <a class="reference external" href="http://sourceforge.net/projects/sqlobject">Sourceforge.net</a>. Fast, secure and Free Open Source software downloads
</div>
</body>
</html>
|