[Zope-CVS] SVN: zversioning/trunk/src/versioning/ Added getPrincipal implementation

Uwe Oestermeier uwe_oestermeier at iwm-kmrc.de
Thu Oct 14 07:22:31 EDT 2004


Log message for revision 28160:
  Added getPrincipal implementation

Changed:
  U   zversioning/trunk/src/versioning/MOTIVATION.txt
  U   zversioning/trunk/src/versioning/README.txt
  U   zversioning/trunk/src/versioning/policies.py
  U   zversioning/trunk/src/versioning/storage.py
  U   zversioning/trunk/src/versioning/tests/test_versioncontrol.py

-=-
Modified: zversioning/trunk/src/versioning/MOTIVATION.txt
===================================================================
--- zversioning/trunk/src/versioning/MOTIVATION.txt	2004-10-14 11:18:48 UTC (rev 28159)
+++ zversioning/trunk/src/versioning/MOTIVATION.txt	2004-10-14 11:22:30 UTC (rev 28160)
@@ -166,7 +166,7 @@
     '001'
     >>> saveAsVersion(c, histories)
     '001'
-    >>> histories.getVersion(a, '001').text
+    >>> histories.getVersion(a, '001').data.text
     'First text version of a'
     
 Add some additional content versions :
@@ -176,15 +176,15 @@
     >>> saveAsVersion(a, histories)
     '002'
     >>> version = histories.getVersion(a, '002')
-    >>> version.text
+    >>> version.data.text
     'Second text version of a'
     >>> saveAsVersion(c, histories)
     '002'
     >>> a001 = histories.getVersion(a, '001')
-    >>> a001.text
+    >>> a001.data.text
     'First text version of a'
     >>> a002 = histories.getVersion(a, '002')
-    >>> a002.text
+    >>> a002.data.text
     'Second text version of a'
     
     Note that after the copy process original and versions

Modified: zversioning/trunk/src/versioning/README.txt
===================================================================
--- zversioning/trunk/src/versioning/README.txt	2004-10-14 11:18:48 UTC (rev 28159)
+++ zversioning/trunk/src/versioning/README.txt	2004-10-14 11:22:30 UTC (rev 28160)
@@ -41,17 +41,28 @@
         to ensure that the changing versions can be accessed later on. 
         We use the abstract term ticket to describe the fact that different
         storages use quite different reference schemes, e.g. global unique ids,
-        paths and revision numbers, python pointers, the _p_oid in the ZODB etc.
+        paths and revision numbers like SVN, python references in the ZODB etc.
         to retrieve and access parts of the history of an object.
         
-    2.  IVersionableAspects. 
+        In the long run we want to be able to plug in
+        other versioning systems like Subversion or relational databases as
+        other backends.
+        
+        
+    2.  IVersionableAspects. A plugin for the replication process that determines
+        what is versioned and how it stored. This is implemented as multiadapter
+        from IVersionable to IHistoriesStorage because only the combination
+        of both is able to determine what is stored in which way.
     
    
-    3.  INameChooser.
+    3.  INameChooser. A plugin for different labelling schemes, e.g. version 1, 
+        version 2, ... vs. v1.0, v1.1, v.1.1.1 etc.
     
     
-    4.  ICheckoutAware.
-    
+    4.  ICheckoutAware. A plugin that adds the ability to mark items as checked out
+        to data storages that do not provide this functionality themselves.    
+
+
     XXX
     
     5.  IMergeStrategies 

Modified: zversioning/trunk/src/versioning/policies.py
===================================================================
--- zversioning/trunk/src/versioning/policies.py	2004-10-14 11:18:48 UTC (rev 28159)
+++ zversioning/trunk/src/versioning/policies.py	2004-10-14 11:22:30 UTC (rev 28160)
@@ -78,14 +78,14 @@
         
         history = self.histories.getVersionHistory(self.versionable)
         version = history[version_specifier]
-        self.copy(version, self.versionable)
+        self.copyVersionedData(version, self.versionable)
               
-    def copy(self, source, target) :
+    def copyVersionedData(self, source, target) :
         """ The internal copy routine """
         parent = target.__parent__
         name = target.__name__       
         del parent[name]
-        IObjectCopier(source).copyTo(parent, name)
+        IObjectCopier(source.data).copyTo(parent, name)
 
 
 class ReplaceWithCopyPolicy(VersionableAspectsAdapter) :
@@ -97,13 +97,13 @@
         references are updated if needed.
     """
     
-    def copy(self, source, target) :
+    def copyVersionedData(self, source, target) :
         """ Replaces the original with a copied version. """
          
         parent = target.__parent__
         name = target.__name__       
         del parent[name]
-        IObjectCopier(source).copyTo(parent, name)
+        IObjectCopier(source.data).copyTo(parent, name)
  
  
 class UpdateStatusPolicy(VersionableAspectsAdapter) :
@@ -115,9 +115,9 @@
         
     """
     
-    def copy(self, source, target) :
+    def copyVersionedData(self, source, target) :
         """ Copies the state of source to target. """
-        for key, value in source.__getstate__().items() :
+        for key, value in source.data.__getstate__().items() :
             if key not in ('__name__', '__parent__') :
                 setattr(target, key, value)
 

Modified: zversioning/trunk/src/versioning/storage.py
===================================================================
--- zversioning/trunk/src/versioning/storage.py	2004-10-14 11:18:48 UTC (rev 28159)
+++ zversioning/trunk/src/versioning/storage.py	2004-10-14 11:22:30 UTC (rev 28160)
@@ -26,6 +26,7 @@
 from zope.app.container.interfaces import INameChooser
 from zope.app.annotation.interfaces import IAnnotations
 from zope.app.uniqueid.interfaces import IUniqueIdUtility
+from zope.app.servicenames import Authentication
 
 from versioning.interfaces import IVersionHistory
 from versioning.interfaces import IHistoryStorage
@@ -33,6 +34,11 @@
 from versioning.interfaces import ICheckoutAware
 
 
+class VersionPrincipalNotFound(Exception):
+    pass
+    
+
+
 class VersionHistory(Folder) :
     """ A simple folder implementation where each version
         is labeled '001', '002' etc.
@@ -157,7 +163,12 @@
         return 'no comment'
     
     def getPrincipal(self):
-        raise NotImplementedError
+        """ Returns the id of the principal that is versioning the data. """  
+        auth = zapi.getService(Authentication)
+        for principal in auth.getPrincipals('') :
+            return principal.getLogin()
+        return VersionPrincipalNotFound
+ 
     
     data = property(getData)
     timestamp = property(getTimestamp)

Modified: zversioning/trunk/src/versioning/tests/test_versioncontrol.py
===================================================================
--- zversioning/trunk/src/versioning/tests/test_versioncontrol.py	2004-10-14 11:18:48 UTC (rev 28159)
+++ zversioning/trunk/src/versioning/tests/test_versioncontrol.py	2004-10-14 11:22:30 UTC (rev 28160)
@@ -75,6 +75,10 @@
 from zope.app.container.contained import NameChooser
 from zope.component.tests.placelesssetup import PlacelessSetup
 
+from versioning.interfaces import IVersion
+from versioning.storage import Version
+
+
 class FakeModule:
     def __init__(self, dict):
         self.__dict = dict
@@ -123,7 +127,9 @@
     ztapi.provideAdapter(None, IObjectCopier, ObjectCopier)
     ztapi.provideAdapter(IWriteContainer, INameChooser, NameChooser)
     ztapi.provideUtility(IUniqueIdUtility, UniqueIdUtility())
-    ztapi.provideAdapter(IPersistent, IReference, ReferenceToPersistent)    
+    ztapi.provideAdapter(IPersistent, IReference, ReferenceToPersistent) 
+    ztapi.provideAdapter(None, IVersion, Version)
+   
 
 
 def setUpReadMe(test) :



More information about the Zope-CVS mailing list