Sophie

Sophie

distrib > Mageia > 6 > x86_64 > media > core-release > by-pkgid > 7100f2b58690d0bf43c8eb8cfe1232ce > files > 880

python-sqlobject-2.1.2-2.mga6.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="content-type">
<title></title>
    <link href="layout.css" type="text/css" rel="stylesheet">
  </head>
  <body>
    <div id="page">
      <h1 class="doc-title"><a></a></h1>
      <div id="navcontainer">
		    <ul id="navlist">
          <li class="pagenav">
            <ul>
              <li class="page_item">
                <a href="index.html" title="Project Home / Index">SQLObject</a>
              </li>
              <li class="page_item">
                <a href="module-index.html" title="sqlobject package and module reference">Modules</a>
              </li>
              <li>
                <a href="community.html" title="Mailing List">Discuss</a>
              </li>
	      <li>
	        <a href="SQLObject.html">Documentation</a>
	      </li>
            </ul>
          </li>
        </ul>
      </div>
      <hr>
      <div id="content"><div class="rst-doc">
  <h1 class="pudge-member-page-heading"></h1>
  <table rules="none" frame="void" class="docinfo">
<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="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 href="Inheritance.html" class="reference external">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 start="2" class="arabic simple">
<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 start="3" class="arabic simple">
<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>
<a href="http://sourceforge.net/projects/sqlobject" class="reference external image-reference"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=74338&amp;type=10" alt="Get SQLObject at SourceForge.net. Fast, secure and Free Open Source software downloads" style="width: 80px; height: 15px;" class="noborder align-center"></a>
</div>
</div>
</div></div>
      <div id="footer">
        <p style="float: left;">
          built with 
          <a href="http://lesscode.org/projects/pudge/">pudge/0.1.3</a> |
		      original design by 
          <a href="http://blog.ratterobert.com/">ratter / robert</a>
	      </p>
        <div>
        <br> <!--
        <a name="search">
          <form method="get" id="searchform" 
                action="http://lesscode.org/blog/index.php">
            <div>
              <input type="text" value="" name="s" id="s" />
              <input type="submit" id="searchsubmit" value="Search" />
            </div>
          </form>
        </a> -->
        <br>
        </div>
      </div>
    </div>
  </body>
</html>