[Zope-CVS] SVN: zversioning/trunk/src/versioning/ objects are now
stored wrapped in the history
Grégoire Weber
zope.org at incept.ch
Thu Oct 14 06:53:13 EDT 2004
Log message for revision 28156:
objects are now stored wrapped in the history
Changed:
U zversioning/trunk/src/versioning/README.txt
U zversioning/trunk/src/versioning/interfaces.py
U zversioning/trunk/src/versioning/storage.py
-=-
Modified: zversioning/trunk/src/versioning/README.txt
===================================================================
--- zversioning/trunk/src/versioning/README.txt 2004-10-14 10:47:16 UTC (rev 28155)
+++ zversioning/trunk/src/versioning/README.txt 2004-10-14 10:53:11 UTC (rev 28156)
@@ -164,7 +164,11 @@
... interfaces.ICopyModifyMergeRepository,
... repository.CheckoutCheckinRepository)
+ >>> ztapi.provideAdapter(None,
+ ... interfaces.IVersion,
+ ... storage.Version)
+
Now we adapt our history storage to the chosen repository strategy:
>>> repo = interfaces.ICopyModifyMergeRepository(histories_storage)
@@ -229,3 +233,9 @@
>>> len(repo.listVersions(sample))
2
+
+ >>> [v.label for v in repo.listVersions(sample)]
+ [u'001', u'002']
+
+ >>> [v.name for v in repo.listVersions(sample)]
+ ['Version 1', 'Version 2']
Modified: zversioning/trunk/src/versioning/interfaces.py
===================================================================
--- zversioning/trunk/src/versioning/interfaces.py 2004-10-14 10:47:16 UTC (rev 28155)
+++ zversioning/trunk/src/versioning/interfaces.py 2004-10-14 10:53:11 UTC (rev 28156)
@@ -38,7 +38,7 @@
import persistent, zope
from zope.interface import Interface, Attribute
-from zope.app.container.interfaces import INameChooser
+from zope.app.container.interfaces import INameChooser, IContained
from zope.app.uniqueid.interfaces import IReference
@@ -226,26 +226,19 @@
"""
-class IVersionableData(Interface) :
- """ An adapter for versionable data. """
+class IVersion(IContained) :
+ """ Versions are snapshots of data that change over time.
+ This interface defines some basic methods each version should
+ fullfill.
+ """
data = Attribute("A read only reference to the versioned data.")
- ticket = Attribute("A read only ticket that is associated with "
- "IVersionableData.")
-
timestamp = Attribute("The read onyl timestamp when the version "
"was stored to the repository")
principal = Attribute("The read only actor of the store action.")
-
-class IVersion(IVersionableData):
- """ Versions are snapshots of data that change over time.
- This interface defines some basic methods each version should
- fullfill.
- """
-
label = Attribute("Short read only string encoding version information.")
name = Attribute("User readable read only string encoding version "
@@ -253,6 +246,7 @@
comment = Attribute("Read only user defined comment.")
+
class IVersionNode(IVersion):
"""In group situations there can be parallel versions that must be
synchronized or merged.
@@ -318,13 +312,20 @@
"""Returns the whole metadata history of the objects aspects.
"""
+
class IVersionable(IReference):
"""Version control is allowed for objects that provide this."""
-
+class IVersioned(IVersionable):
+ """Version control is in effect for this object."""
+
+
+
class IMultiClientStorage(Interface) :
""" if the repository allows several ways to
create versions and not only reacts to Zope calls.
+
+ XXX Not yet landed.
"""
def triggerEvents(ticket=None) :
@@ -339,12 +340,5 @@
"""
-class IVersionable(persistent.interfaces.IPersistent,
- zope.app.annotation.interfaces.IAnnotatable):
- """Version control is allowed for objects that provide this."""
-class IVersioned(IVersionable):
- """Version control is in effect for this object."""
-
-
# XXX describe generated events here
Modified: zversioning/trunk/src/versioning/storage.py
===================================================================
--- zversioning/trunk/src/versioning/storage.py 2004-10-14 10:47:16 UTC (rev 28155)
+++ zversioning/trunk/src/versioning/storage.py 2004-10-14 10:53:11 UTC (rev 28156)
@@ -29,6 +29,7 @@
from versioning.interfaces import IVersionHistory
from versioning.interfaces import IHistoryStorage
+from versioning.interfaces import IVersion
from versioning.interfaces import ICheckoutAware
@@ -39,7 +40,7 @@
implements(IVersionHistory, INameChooser)
- def checkName(self, name, object):
+ def checkName(self, name, obj):
"""Check whether an object name is valid.
Raise a user error if the name is not valid.
@@ -47,7 +48,7 @@
raise UserError("versions cannot be named by the user.")
- def chooseName(self, name, object):
+ def chooseName(self, name, obj):
"""Choose a unique valid name for the object
The given name and object may be taken into account when
@@ -56,9 +57,16 @@
"""
return "%03d" % (len(self)+1)
-
+ # del verbieten
+ def __setitem__(self, key, obj):
+ """
+ """
+ info = IVersion(obj)
+ super(VersionHistory, self).__setitem__(key, info)
+
+
class SimpleHistoryStorage(Folder) :
"""
Implements the probably most simple way of version control in Zope3.
@@ -120,19 +128,55 @@
return history
+class Version(object) :
+ """An adapter for versionable data.
+ """
+
+ implements(IVersion)
+
+ __parent__ = __name__ = None
+
+ def __init__(self, obj):
+ self.obj = obj
+ self.time = datetime.now()
+
+ def getData(self):
+ return self.obj
+
+ def getTimestamp(self):
+ return self.time
+
+ def getLabel(self):
+ return self.__name__
+
+ def getName(self):
+ return 'Version %d' % int(self.getLabel())
+
+
+ def getComment(self):
+ return 'no comment'
+
+ def getPrincipal(self):
+ raise NotImplementedError
+
+ data = property(getData)
+ timestamp = property(getTimestamp)
+ label = property(getLabel)
+ name = property(getName)
+
+ comment = property(getComment)
+ principal = property(getPrincipal)
+
+
+
class DefaultCheckoutAware(object):
"""Default checkout and checkin aware storage extension.
- Use this for IHistoryStorage components beeing unable to store checkin
- and checkout information.
+ Restrictions:
- XXX Should 'DefaultCheckoutAware' live here?
-
- XXX CAUTION! If currently a checked out object gets deleted
- the counter doesn't get decremented! We should
-
- Asserts IContained (the same object can not live in different
- locations).
+ Asserts IContained (the same object can not live in different
+ locations). If currently a checked out object gets deleted
+ the counter doesn't get decremented!
"""
implements(ICheckoutAware)
More information about the Zope-CVS
mailing list