[Zope-CVS] SVN: zversioning/trunk/src/versioning/ got doc tests
running and fixed some minor bugs
Grégoire Weber
zope.org at incept.ch
Wed Oct 13 17:33:14 EDT 2004
Log message for revision 28137:
got doc tests running and fixed some minor bugs
Changed:
U zversioning/trunk/src/versioning/README.txt
U zversioning/trunk/src/versioning/repository.py
-=-
Modified: zversioning/trunk/src/versioning/README.txt
===================================================================
--- zversioning/trunk/src/versioning/README.txt 2004-10-13 21:21:46 UTC (rev 28136)
+++ zversioning/trunk/src/versioning/README.txt 2004-10-13 21:33:12 UTC (rev 28137)
@@ -19,12 +19,17 @@
>>> from zope.app.tests.setup import setUpTraversal
>>> from zope.app.traversing.interfaces import IPhysicallyLocatable
>>> from ZODB.tests import util
+ >>> from versioning.tests.test_versioncontrol import buildRepository, buildDatabaseRoot
+ >>> db_root = buildDatabaseRoot()
+
>>> class TestFolder(Folder) :
... zope.interface.implements(IPhysicallyLocatable)
... def getPath(self) :
... return ""
>>> sample = TestFolder()
>>> directlyProvides(sample, zope.app.traversing.interfaces.IContainmentRoot)
+ >>> db_root['sample'] = sample
+
>>> a = sample["a"] = TestFolder()
>>> b = sample["b"] = TestFolder()
>>> c = b["c"] = TestFolder()
@@ -33,14 +38,17 @@
>>> [x for x in sample.keys()]
[u'a', u'b']
- >>> from versioning.tests.test_versioncontrol import buildRepository, buildDatabaseRoot
- >>> db_root = buildDatabaseRoot()
-
-
-
-CopyModifyMergeRepository Setup Explained
------------------------------------------
+The chosen 'IHistoryStorage' component expects the objects having
+a '_p_oid'.
+XXX We know this is an implementation detail. We probably should think
+more about this and then talk about this in the interfaces.
+ >>> util.commit()
+
+
+Setting up a Repository
+-----------------------
+
In this architecture we can choose between several repositories. We take a
CopyModifyMergeRepository without check in and check out as an example.
@@ -71,8 +79,8 @@
Register a 'ICheckoutAware' adapter to a 'IHistoryStorage' that
handles the checkout/checkin status for the repository.
- >>> ztapi.provideAdapter(interfaces.ICheckoutAware,
- ... interfaces.IHistoryStorage,
+ >>> ztapi.provideAdapter(interfaces.IHistoryStorage,
+ ... interfaces.ICheckoutAware,
... repository.DummyCheckoutAware)
In this implementation the repository is simply a adapter to a
@@ -81,15 +89,15 @@
>>> ztapi.provideAdapter(interfaces.IHistoryStorage,
... interfaces.ICopyModifyMergeRepository,
- ... repository.CopyModifyMergeRepository)
+ ... repository.CheckoutCheckinRepository)
Now we adapt our history storage to the chosen repository strategy:
>>> repo = interfaces.ICopyModifyMergeRepository(histories_storage)
-CopyModifyMergeRepository Usage Explained
------------------------------------------
+Use the CheckoutCheckinRepository
+---------------------------------
An object that isn't 'IVersionable' can't be put under version control.
Applying version control should raise an exception:
@@ -111,12 +119,6 @@
>>> a.text = "text version 1 of a"
>>> c.text = "text version 1 of a"
-The chosen 'IHistoryStorage' component expects the objects having
-a '_p_oid'.
-XXX We know this is an implementation detail. We probably should think
-more about this and then talk about this in the interfaces.
-
-
Now let's put our example data under version control:
>>> repo.applyVersionControl(sample)
@@ -150,6 +152,7 @@
>>> repo.checkout(sample)
>>> repo.text = 'text version 2 of sample'
>>> repo.checkin(sample)
+
#>>> len(repo.getVersionHistory(sample))
2
>>>
\ No newline at end of file
Modified: zversioning/trunk/src/versioning/repository.py
===================================================================
--- zversioning/trunk/src/versioning/repository.py 2004-10-13 21:21:46 UTC (rev 28136)
+++ zversioning/trunk/src/versioning/repository.py 2004-10-13 21:33:12 UTC (rev 28137)
@@ -40,6 +40,9 @@
zope.interface.implements(interfaces.ICheckoutAware)
__used_for__ = interfaces.IHistoryStorage
+ def __init__(self, histories):
+ self.histories = histories
+
def markAsCheckedIn(self, obj):
"""Fake checkin mark doing anything.
"""
@@ -155,18 +158,18 @@
XXX Other exceptions (for repository problems)?
"""
# the order may be significant for the marking, XXX really?
- checkoutaware = ICheckoutAware(self.histories)
+ checkoutaware = interfaces.ICheckoutAware(self.histories)
checkoutaware.markAsCheckedIn(obj)
self._saveAsVersion(obj)
def checkout(self, obj):
"""Marks the object as checked out (being in use somehow).
"""
- checkoutaware = ICheckoutAware(self.histories)
+ checkoutaware = interfaces.ICheckoutAware(self.histories)
checkoutaware.markAsCheckedOut(obj)
def isCheckedOut(self, obj):
- checkoutaware = ICheckoutAware(self.histories)
+ checkoutaware = interfaces.ICheckoutAware(self.histories)
return checkoutaware.isCheckedOut(obj)
More information about the Zope-CVS
mailing list