[Zope-CVS] SVN: zversioning/trunk/src/versioning/storage.py readded lost getPrincipal code

Grégoire Weber zope.org at incept.ch
Thu Oct 14 08:43:21 EDT 2004


Log message for revision 28173:
  readded lost getPrincipal code

Changed:
  U   zversioning/trunk/src/versioning/storage.py

-=-
Modified: zversioning/trunk/src/versioning/storage.py
===================================================================
--- zversioning/trunk/src/versioning/storage.py	2004-10-14 12:32:46 UTC (rev 28172)
+++ zversioning/trunk/src/versioning/storage.py	2004-10-14 12:43:20 UTC (rev 28173)
@@ -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.
@@ -152,11 +158,17 @@
     def getName(self):
         return 'Version %d' % int(self.getLabel())
         
+        
     def getComment(self):
         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)



More information about the Zope-CVS mailing list