[Zope-CVS] SVN: zversioning/trunk/src/versioning/ blah
Grégoire Weber
zope.org at incept.ch
Wed Oct 13 11:35:21 EDT 2004
Log message for revision 28101:
blah
Changed:
U zversioning/trunk/src/versioning/README.txt
U zversioning/trunk/src/versioning/interfaces.py
U zversioning/trunk/src/versioning/policies.py
U zversioning/trunk/src/versioning/repository.py
U zversioning/trunk/src/versioning/storage.py
-=-
Modified: zversioning/trunk/src/versioning/README.txt
===================================================================
--- zversioning/trunk/src/versioning/README.txt 2004-10-13 15:33:16 UTC (rev 28100)
+++ zversioning/trunk/src/versioning/README.txt 2004-10-13 15:35:19 UTC (rev 28101)
@@ -16,8 +16,6 @@
>>> import zope.app.versioncontrol.interfaces
>>> from zope.interface import directlyProvides
- >>> from zope.app.versioncontrol.repository import declare_versioned
- >>> from versioning.tests.repository_setup import registerAdapter
>>> from zope.app.folder import Folder, rootFolder
>>> from zope.app.tests.setup import setUpTraversal
>>> from zope.app.traversing.interfaces import IPhysicallyLocatable
@@ -90,7 +88,7 @@
Now we adapt our history storage to the chosen repository strategy:
- >>> repository = interfaces.ICopyModifyMergeRepository(histories_storage)
+ >>> repo = interfaces.ICopyModifyMergeRepository(histories_storage)
CopyModifyMergeRepository Usage Explained
@@ -99,7 +97,7 @@
An object that isn't 'IVersionable' can't be put under version control.
Applying version control should raise an exception:
- >>> repository.applyVersionControl(a)
+ >>> repo.applyVersionControl(a)
Traceback (most recent call last):
RepositoryError: This resource cannot be put under version control.
@@ -121,20 +119,20 @@
Now let's put our example data under version control:
- >>> repository.applyVersionControl(sample)
- >>> repository.applyVersionControl(a)
- >>> repository.applyVersionControl(b)
- >>> repository.applyVersionControl(c)
+ >>> repo.applyVersionControl(sample)
+ >>> repo.applyVersionControl(a)
+ >>> repo.applyVersionControl(b)
+ >>> repo.applyVersionControl(c)
>>> [interfaces.IVersioned.providedBy(x) for x in (sample, a, b, c)]
[True, True, True, True]
- >>>
+ #>>> repo.isCheckedOut(a)
+ False
+ #>>> #repo.checkout(a)
+ #>>> #repo.isCheckedOut(a)
+ True
+
+
- >>> def accessVersion(repository, obj) :
- ... info = repository.getVersionInfo(obj)
- ... return repository.getVersionOfResource(info.history_id, 'mainline')
- >>> new_a = accessVersion(repository, a)
- >>> new_b = accessVersion(repository, b)
- >>> new_c = accessVersion(repository, c)
- >>> [x for x in sample.keys()]
- [u'a', u'b']
+ #>>> len(repo.getVersionHistory(sample))
+ 1
Modified: zversioning/trunk/src/versioning/interfaces.py
===================================================================
--- zversioning/trunk/src/versioning/interfaces.py 2004-10-13 15:33:16 UTC (rev 28100)
+++ zversioning/trunk/src/versioning/interfaces.py 2004-10-13 15:35:19 UTC (rev 28101)
@@ -40,8 +40,9 @@
from zope.app.container.interfaces import INameChooser
+class RepositoryError(Exception):
+ pass
-
class IRepository(Interface):
"""A version repository providing core functionality.
@@ -56,13 +57,25 @@
versioned aspects). XXX After having deleted the last object
the IHistoryStorage component has to be asked for a bootstrap
object.
+
+ ToDo:
+
+ - removeFromVersionControl: meant to be the opposite of
+ applyVersionControl (what's the opposite?)
+ - deleteVersionHistory: meant to delete the history, heavy!!!!
+ We have to think about use cases and what the framework
+ shall support. 99.99% YAGNI
"""
def applyVersionControl(obj):
"""Put the an object under version control.
-
+
This method has to be call prior using any other repository
- related methods.
+ related methods. The objects current state gets saved as first
+ version.
+
+ XXX Different comments apply for different repositories. Where
+ to put this?
"""
def revertToVersion(obj, selector):
@@ -76,6 +89,16 @@
"""Top level API for a copy-modify-merge (subversion like) repository.
"""
+ def applyVersionControl(obj):
+ """Put the an object under version control.
+
+ This method has to be call prior using any other repository
+ related methods. The objects current state gets saved as first
+ version.
+
+ After this operation the object is in checked in state.
+ """
+
def saveAsVersion(obj, metadata=None):
"""Save the current state of the object for later retreival.
"""
@@ -86,7 +109,7 @@
These kind of repositories administrate an "object is in use"
information which may be suitable in some environments.
- It my be seen as kind of soft locks.
+ The Checkin/Checkout information may be seen as kind of soft lock.
"""
def checkout(obj):
@@ -133,7 +156,7 @@
does). Instead it returns the version as new object.
"""
- def listVersions(obj):
+ def getVersionHistory(obj):
"""Returns all versions of the given object.
XXX YAGNI? This was the former 'getVersionIds'.
@@ -189,7 +212,7 @@
do that?
"""
- def writeAspects():
+ def writeAspects(metadata=None):
"""Write an aspect from the original object.
"""
@@ -213,14 +236,6 @@
XXX copy or ref?
"""
- def getVersionHistory(obj):
- """Returns the whole version history of the object.
- """
-
- def getMetadataHistory(obj):
- """Returns the whole metadata history of the object.
- """
-
class ITicket(Interface) :
""" A marker interface for access information for versioned data.
@@ -252,8 +267,7 @@
-# XXX
-class IHistoryStorage(Interface) : # IHistories
+class IHistoryStorage(Interface) : # IHistoriesStorage?
""" Minimal interface for a pluggable storage that stores a new version
of an object into an object history.
@@ -264,7 +278,7 @@
IHistoryStorage components store IVersionableAspects of objects.
"""
- def register(obj) :
+ def register(obj):
""" Puts some object under version control. Returns an IHistory.
Why register?
@@ -274,10 +288,23 @@
exceptions or similar)
"""
- def getVersion(history, selector):
+ def getTicket(obj):
+ """ Returns the persistent oid of an object as
+ a ticket that remains stable across time.
"""
+
+ def getVersion(obj, selector):
+ """ Returns the version of an object that is specified by selector.
"""
+
+ def getObjectHistory(obj):
+ """Returns the whole version history of the objects aspects.
+ """
+ def getMetadataHistory(obj):
+ """Returns the whole metadata history of the objects aspects.
+ """
+
class IVersionable(persistent.interfaces.IPersistent):
"""Version control is allowed for objects that provide this."""
Modified: zversioning/trunk/src/versioning/policies.py
===================================================================
--- zversioning/trunk/src/versioning/policies.py 2004-10-13 15:33:16 UTC (rev 28100)
+++ zversioning/trunk/src/versioning/policies.py 2004-10-13 15:35:19 UTC (rev 28101)
@@ -60,11 +60,12 @@
self.versionable = versionable
self.histories = histories
- def writeAspects(self) :
+ def writeAspects(self, message=None) :
"""
Save the versionable aspects of an original object into
the object history.
- """
+ """
+ # XXX we currently throw away the message
history = self.histories.getHistory(self.versionable)
return IObjectCopier(self.versionable).copyTo(history)
Modified: zversioning/trunk/src/versioning/repository.py
===================================================================
--- zversioning/trunk/src/versioning/repository.py 2004-10-13 15:33:16 UTC (rev 28100)
+++ zversioning/trunk/src/versioning/repository.py 2004-10-13 15:35:19 UTC (rev 28101)
@@ -20,7 +20,7 @@
from zope.interface import Interface
from zope.app import zapi
-import interfaces
+from versioning import interfaces
# doc tests import
import unittest
@@ -33,6 +33,8 @@
Use this for IHistoryStorage components beeing unable to store checkin
and checkout information.
+
+ XXX Should 'DummyCheckoutAware' live here?
"""
zope.interface.implements(interfaces.ICheckoutAware)
@@ -62,19 +64,19 @@
interfaces.IIntrospectableRepository,
)
- def __init__(self):
- self.histories = zapi.getUtility(interfaces.IHistoryStorage)
+ def __init__(self, histories):
+ self.histories = histories
- def applyVersionControl(self, obj):
+ def applyVersionControl(self, obj, metadata=None):
"""Put the passed object under version control.
"""
if interfaces.IVersioned.providedBy(obj):
- raise RepositoryError(
+ raise interfaces.RepositoryError(
'The resource is already under version control.'
)
if not interfaces.IVersionable.providedBy(obj):
- raise RepositoryError(
+ raise interfaces.RepositoryError(
'This resource cannot be put under version control.'
)
@@ -88,25 +90,30 @@
# raise "connection to backend repository lost" or "quota for
# user John exceded" exceptions or similar)
self.histories.register(obj)
+
+ # save initial version
+ versionable_state = zapi.getMultiAdapter(
+ (obj, self.histories), interfaces.IVersionableAspects)
+ versionable_state.writeAspects(metadata)
- def _declare_versioned(obj):
+ def _declare_versioned(self, obj):
"""Apply bookkeeping needed to recognize an object version controlled.
"""
ifaces = zope.interface.directlyProvidedBy(obj)
- ifaces += IVersioned
+ ifaces += interfaces.IVersioned
zope.interface.directlyProvides(obj, *ifaces)
- def saveAsVersion(self, obj):
+ def saveAsVersion(self, obj, metadata=None):
"""Save the current state of the object for later retreival.
"""
self._saveAsVersion(self, obj)
- def _saveAsVersion(self, obj):
+ def _saveAsVersion(self, obj, metadata=None):
"""Save the current state of the object for later retreival.
"""
versionable_state = zapi.getMultiAdapter(
- (obj, self.histories), IVersionableAspects)
- versionable_state.writeAspect()
+ (obj, self.histories), interfaces.IVersionableAspects)
+ versionable_state.writeAspects(metadata)
def revertToVersion(self, obj, selector):
"""Reverts the object to the selected version.
@@ -114,7 +121,7 @@
XXX Do we need to say something about branches?
"""
versionable_state = zapi.getMultiAdapter(
- (obj, self.histories), IVersionableAspects)
+ (obj, self.histories), interfaces.IVersionableAspects)
versionable_state.updateAspects(specifier)
def getVersionHistory(self, obj):
@@ -122,8 +129,8 @@
def getMetadataHistory(self, obj):
return self.histories.getMetadataHistory(obj)
-
+
class CheckoutCheckinRepository(CopyModifyMergeRepository):
"""The repository handles simple linear histories.
"""
@@ -138,7 +145,7 @@
# confuse the checkout/checkin management
raise NotImplementedError
- def checkin(self, obj):
+ def checkin(self, obj, metadata=None):
"""Check in an IVersionable object.
Raises an RepositoryError if the object is not versionable.
Modified: zversioning/trunk/src/versioning/storage.py
===================================================================
--- zversioning/trunk/src/versioning/storage.py 2004-10-13 15:33:16 UTC (rev 28100)
+++ zversioning/trunk/src/versioning/storage.py 2004-10-13 15:35:19 UTC (rev 28101)
@@ -19,8 +19,8 @@
from zope.app.folder import Folder
from zope.app.exception.interfaces import UserError
-from interfaces import IVersionHistory
-from interfaces import IHistoryStorage
+from versioning.interfaces import IVersionHistory
+from versioning.interfaces import IHistoryStorage
@@ -59,7 +59,7 @@
the _p_oid as an identification ticket for objects and their versions
a Folder as a container for histories were each History is itself a Folder
- >>> from policies import VersionableAspectsAdapter
+ >>> from versioning.policies import VersionableAspectsAdapter
>>> from zope.app.tests.setup import buildSampleFolderTree
>>> sample = buildSampleFolderTree()
>>> histories = SimpleHistoryStorage()
@@ -69,7 +69,6 @@
implements(IHistoryStorage)
-
def getTicket(self, obj) :
""" Returns the persistent oid of an object as
a ticket that remains stable across time.
More information about the Zope-CVS
mailing list