[Zope-CVS] SVN: zversioning/trunk/src/versioning/ Added tests in
MOTIVATION.txt
Uwe Oestermeier
uwe_oestermeier at iwm-kmrc.de
Wed Oct 13 18:41:43 EDT 2004
Log message for revision 28140:
Added tests in MOTIVATION.txt
Changed:
U zversioning/trunk/src/versioning/MOTIVATION.txt
U zversioning/trunk/src/versioning/policies.py
U zversioning/trunk/src/versioning/storage.py
-=-
Modified: zversioning/trunk/src/versioning/MOTIVATION.txt
===================================================================
--- zversioning/trunk/src/versioning/MOTIVATION.txt 2004-10-13 22:39:38 UTC (rev 28139)
+++ zversioning/trunk/src/versioning/MOTIVATION.txt 2004-10-13 22:41:42 UTC (rev 28140)
@@ -184,6 +184,19 @@
'Second text version of a'
>>> saveAsVersion(c, histories)
'002'
+ >>> a001 = histories.getVersion(a, '001')
+ >>> a001.text
+ 'First text version of a'
+ >>> a002 = histories.getVersion(a, '002')
+ >>> a002.text
+ 'Second text version of a'
+
+ Note that after the copy process original and versions
+ are all distinct object :
+
+ >>> a != a001 != a002
+ True
+
Now let's update the original object with versioned data. This again is a matter
of the policy. The simple implementation here replaces the original data
@@ -207,7 +220,8 @@
>>> new_c.refers_to == a
True
-The more interesting case arises if we update the refered object too :
+The more interesting case arises if we update the object that has
+been referenced :
>>> revertToVersionCopy(a, histories, '001')
>>> new_a = sample["a"]
@@ -218,9 +232,9 @@
Depending on the use case this might be what you want.
- >>> util.commit()
+
A Second Implementation
=======================
@@ -233,19 +247,32 @@
does not replace the original with a copy but updates only all fields
with the versioned values.
-#
-# >>> def revertToVersionState(obj, histories, selector) :
-# ... adapter = versioning.policies.UpdateStatusPolicy(obj, histories)
-# ... adapter.updateAspects(selector)
-# >>> a = new_a
-# >>> a.text
-# 'First text version of a'
-# >>> revertToVersionState(new_a, histories, '002')
-# >>> a.text
-# 'Second text version of a'
-# >>> a == new_a
-# True
-#
+
+ >>> def revertToVersionState(obj, histories, selector) :
+ ... adapter = versioning.policies.UpdateStatusPolicy(obj, histories)
+ ... adapter.updateAspects(selector)
+ >>> new_a = a
+ >>> a.text
+ 'Second text version of a'
+ >>> revertToVersionState(a, histories, '001')
+ >>> a.text
+ 'First text version of a'
+ >>> a == new_a
+ True
+ >>> revertToVersionState(a, histories, '002')
+ >>> a.text
+ 'Second text version of a'
+ >>> a == new_a
+ True
+
+ Note that the versions and the objects are all different:
+
+ >>> a != a001 != a002
+ True
+ >>> c.refers_to == a
+ True
+
+
@@ -254,4 +281,3 @@
-
Modified: zversioning/trunk/src/versioning/policies.py
===================================================================
--- zversioning/trunk/src/versioning/policies.py 2004-10-13 22:39:38 UTC (rev 28139)
+++ zversioning/trunk/src/versioning/policies.py 2004-10-13 22:41:42 UTC (rev 28140)
@@ -116,7 +116,7 @@
def copy(self, source, target) :
""" Copies the state of source to target. """
- for key, value in source.__getstate__.items() :
+ for key, value in source.__getstate__().items() :
if key not in ('__name__', '__parent__') :
setattr(target, key, value)
Modified: zversioning/trunk/src/versioning/storage.py
===================================================================
--- zversioning/trunk/src/versioning/storage.py 2004-10-13 22:39:38 UTC (rev 28139)
+++ zversioning/trunk/src/versioning/storage.py 2004-10-13 22:41:42 UTC (rev 28140)
@@ -104,7 +104,7 @@
def getVersion(self, obj, selector) :
""" Returns the version of an object that is specified by selector. """
- history = self.getHistory(obj)
+ history = self.getVersionHistory(obj)
return history[selector]
More information about the Zope-CVS
mailing list