[Zope-CVS] SVN: zversioning/trunk/src/versioning/ moved
DefaultCheckoutAware to storage.py
Grégoire Weber
zope.org at incept.ch
Wed Oct 13 19:16:26 EDT 2004
Log message for revision 28141:
moved DefaultCheckoutAware to storage.py
Changed:
U zversioning/trunk/src/versioning/README.txt
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 22:41:42 UTC (rev 28140)
+++ zversioning/trunk/src/versioning/README.txt 2004-10-13 23:16:25 UTC (rev 28141)
@@ -82,7 +82,7 @@
>>> ztapi.provideAdapter(interfaces.IHistoryStorage,
... interfaces.ICheckoutAware,
- ... repository.DefaultCheckoutAware)
+ ... storage.DefaultCheckoutAware)
Our 'ICheckoutAware' adapter XXX
Modified: zversioning/trunk/src/versioning/repository.py
===================================================================
--- zversioning/trunk/src/versioning/repository.py 2004-10-13 22:41:42 UTC (rev 28140)
+++ zversioning/trunk/src/versioning/repository.py 2004-10-13 23:16:25 UTC (rev 28141)
@@ -19,69 +19,15 @@
import zope.interface
from zope.interface import Interface
from zope.app import zapi
-from zope.app.annotation.interfaces import IAnnotations
from versioning import interfaces
-from datetime import datetime
-# doc tests import
+# doc tests imports
import unittest
from zope.testing import doctest
from zope.app.tests import ztapi
-from persistent.dict import PersistentDict
-class DefaultCheckoutAware(object):
- """Just ignores checkin and checkout without generating exceptions.
-
- Use this for IHistoryStorage components beeing unable to store checkin
- and checkout information.
-
- 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).
- """
-
- zope.interface.implements(interfaces.ICheckoutAware)
- __used_for__ = interfaces.IHistoryStorage
-
- namespace_key = 'versioning.interfaces.ICheckoutAware'
-
- def getCheckedOutList(self):
- return self.annotations.get(self.namespace_key)
-
- checkedOutDict = property(getCheckedOutList)
-
- def __init__(self, histories):
- self.histories = histories
- self.annotations = anno = IAnnotations(histories)
- data = self.getCheckedOutList()
- if data is None:
- anno[self.namespace_key] = PersistentDict()
-
- def markAsCheckedOut(self, obj):
- """See versioning.interfaces.ICheckoutAware
- """
- ticket = self.histories.getTicket(obj)
- self.checkedOutDict[ticket] = datetime.now()
-
- def markAsCheckedIn(self, obj):
- """See versioning.interfaces.ICheckoutAware
- """
- ticket = self.histories.getTicket(obj)
- del self.checkedOutDict[ticket]
-
- def isCheckedOut(self, obj):
- """See versioning.interfaces.ICheckoutAware
- """
- ticket = self.histories.getTicket(obj)
- return self.checkedOutDict.has_key(ticket)
-
-
class CopyModifyMergeRepository(object):
"""The repository handles simple linear histories.
"""
Modified: zversioning/trunk/src/versioning/storage.py
===================================================================
--- zversioning/trunk/src/versioning/storage.py 2004-10-13 22:41:42 UTC (rev 28140)
+++ zversioning/trunk/src/versioning/storage.py 2004-10-13 23:16:25 UTC (rev 28141)
@@ -13,18 +13,21 @@
##############################################################################
import unittest, doctest
+from datetime import datetime
from zope.interface import implements
+from persistent.dict import PersistentDict
+from zope.app.folder import Folder
+from zope.app.exception.interfaces import UserError
from zope.app.copypastemove.interfaces import IObjectCopier
from zope.app.container.interfaces import INameChooser
-from zope.app.folder import Folder
-from zope.app.exception.interfaces import UserError
+from zope.app.annotation.interfaces import IAnnotations
from versioning.interfaces import IVersionHistory
from versioning.interfaces import IHistoryStorage
+from versioning.interfaces import ICheckoutAware
-
class VersionHistory(Folder) :
""" A simple folder implementation where each version
is labeled '001', '002' etc.
@@ -104,15 +107,61 @@
def getVersion(self, obj, selector) :
""" Returns the version of an object that is specified by selector. """
- history = self.getVersionHistory(obj)
+ history = self.getHistory(obj)
return history[selector]
+
+
+class DefaultCheckoutAware(object):
+ """Default checkout and checkin aware storage extension.
+
+ Use this for IHistoryStorage components beeing unable to store checkin
+ and checkout information.
+
+ 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).
+ """
+
+ implements(ICheckoutAware)
+ __used_for__ = IHistoryStorage
+
+ namespace_key = 'versioning.interfaces.ICheckoutAware'
+
+ def getCheckedOutList(self):
+ return self.annotations.get(self.namespace_key)
+
+ checkedOutDict = property(getCheckedOutList)
+
+ def __init__(self, histories):
+ self.histories = histories
+ self.annotations = anno = IAnnotations(histories)
+ data = self.getCheckedOutList()
+ if data is None:
+ anno[self.namespace_key] = PersistentDict()
+
+ def markAsCheckedOut(self, obj):
+ """See versioning.interfaces.ICheckoutAware
+ """
+ ticket = self.histories.getTicket(obj)
+ self.checkedOutDict[ticket] = datetime.now()
-
-
-
+ def markAsCheckedIn(self, obj):
+ """See versioning.interfaces.ICheckoutAware
+ """
+ ticket = self.histories.getTicket(obj)
+ del self.checkedOutDict[ticket]
+
+ def isCheckedOut(self, obj):
+ """See versioning.interfaces.ICheckoutAware
+ """
+ ticket = self.histories.getTicket(obj)
+ return self.checkedOutDict.has_key(ticket)
-
def test_suite():
return unittest.TestSuite((
doctest.DocTestSuite(),
More information about the Zope-CVS
mailing list