[Zope-CVS] SVN: zversioning/trunk/src/versioning/tests/ Reference
example works now.
Uwe Oestermeier
uwe_oestermeier at iwm-kmrc.de
Sun Oct 10 09:20:23 EDT 2004
Log message for revision 27901:
Reference example works now.
Changed:
U zversioning/trunk/src/versioning/tests/README.txt
U zversioning/trunk/src/versioning/tests/repository_setup.py
-=-
Modified: zversioning/trunk/src/versioning/tests/README.txt
===================================================================
--- zversioning/trunk/src/versioning/tests/README.txt 2004-10-10 13:20:00 UTC (rev 27900)
+++ zversioning/trunk/src/versioning/tests/README.txt 2004-10-10 13:20:22 UTC (rev 27901)
@@ -46,10 +46,10 @@
In order to show some limitations of the current implementation we use a
prebuild version control repository :
- >>> from versioning.tests.repository_setup import buildOldStyleRepository, buildDatabaseRoot
+ >>> from versioning.tests.repository_setup import buildRepository, buildDatabaseRoot
>>> db_root = buildDatabaseRoot()
>>> db_root["sample"] = sample
- >>> repository = buildOldStyleRepository()
+ >>> repository = buildRepository()
The current policy forces us to remove __parent__ and __name__. We'll do that
by specializing the standard adapter that removes nothing:
@@ -91,12 +91,42 @@
>>> new_c.refers_to == new_a
False
+This demonstrates that the reference to a is not correctly preserved. To
+achieve this goal we overwrite some methods :
+ >>> class RefertialVersionControl(Repository) :
+ ... # an implementation that preprocesses the object states
+ ...
+ ... def applyVersionControl(self, object, message) :
+ ... obj = self.preprocess(object)
+ ... super(RefertialVersionControl, self).applyVersionControl(obj, message)
+ ...
+ ... def getVersionOfResource(self, history_id, branch) :
+ ... obj = super(RefertialVersionControl, self).getVersionOfResource(history_id, branch)
+ ... return self.postprocess(obj)
+ ...
+ ... def preprocess(self, obj) :
+ ... # We replace python references by unique ids
+ ...
+
+ >>> repository2 = buildRepository(RefertialVersionControl)
+ >>> repository2.applyVersionControl(sample)
+ >>> repository2.applyVersionControl(a)
+ >>> repository2.applyVersionControl(b)
+ >>> repository2.applyVersionControl(c)
+
+
+ >>> new_a = accessVersion(repository2, a)
+ >>> new_c = accessVersion(repository2, c)
+ >>> new_c.refers_to == new_a
+ True
+
+
Extensions: We want to define a repository that works as a black box and returns
only a ticket which guarantees that we get a valid copy back if we use this ticket.
Modified: zversioning/trunk/src/versioning/tests/repository_setup.py
===================================================================
--- zversioning/trunk/src/versioning/tests/repository_setup.py 2004-10-10 13:20:00 UTC (rev 27900)
+++ zversioning/trunk/src/versioning/tests/repository_setup.py 2004-10-10 13:20:22 UTC (rev 27901)
@@ -57,7 +57,7 @@
connection = db.open()
return connection.root()
-def buildOldStyleRepository():
+def buildRepository(factory=zope.app.versioncontrol.repository.Repository):
"""Setup a zope.app.versioncontrol repository
Placing an object under version control requires an instance of an
@@ -70,7 +70,7 @@
import zope.app.versioncontrol.repository
import zope.interface.verify
- repository = zope.app.versioncontrol.repository.Repository()
+ repository = factory()
assert zope.interface.verify.verifyObject(
interfaces.IVersionControl,
repository)
More information about the Zope-CVS
mailing list