[Checkins] SVN: z3c.vcsync/trunk/src/z3c/vcsync/ Rearrange and document interfaces a bit better.

Martijn Faassen faassen at infrae.com
Tue Mar 11 13:45:20 EDT 2008


Log message for revision 84582:
  Rearrange and document interfaces a bit better.
  

Changed:
  U   z3c.vcsync/trunk/src/z3c/vcsync/interfaces.py
  U   z3c.vcsync/trunk/src/z3c/vcsync/svn.py

-=-
Modified: z3c.vcsync/trunk/src/z3c/vcsync/interfaces.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/interfaces.py	2008-03-11 16:12:34 UTC (rev 84581)
+++ z3c.vcsync/trunk/src/z3c/vcsync/interfaces.py	2008-03-11 17:45:19 UTC (rev 84582)
@@ -1,74 +1,75 @@
 from zope.interface import Interface, Attribute
 
-class IVcDump(Interface):
-    def save(checkout, path):
-        """Save context object to path in checkout.
+class ISerializer(Interface):
+    """Serialize an object to a file object.
 
-        checkout - an ICheckout object
-        path - a py.path object referring to directory to save in.
-
-        This might result in the creation of a new file or directory under
-        the path, or alternatively to the modification of an existing file
-        or directory.
-
-        Returns the path just created.
-        """
-
-class ISerializer(Interface):
+    Implement this interface for your objects (or through an adapter) to
+    let vcsync serialize it.
+    """
     def serialize(f):
         """Serialize object to file object.
-        """
 
-class IParser(Interface):
-    def parse(f):
-        """Parse object and load it into new object, returning it.
+        f - an open file object to serialize this object to
         """
 
-    def parse_into(f):
-        """Parse object and replace current object's content with it.
-        """
 
 class IVcFactory(Interface):
-    def __call__():
+    """Load object from the filesystem.
+
+    Implement this interface for your objects (or through an adapter) to
+    let vcsync to be able to create new objects based on objects in the
+    filesystem.
+    """
+    
+    def __call__(path):
         """Create new instance of object.
+
+        path - a py.path reference to the object to load from the filesystem
         """
 
-class ISynchronizer(Interface):
-    """Synchronizer between state and version control.
+class IState(Interface):
+    """Information about Python object state.
+
+    This is object represents the state and contains information about
+    what objects in the state have been changed/added, or
+    removed. This information is used to determine what to synchronize
+    to the filesystem.
+    
+    Implement this for the state structure (such as a container tree)
+    you want to export.
     """
-    checkout = Attribute('Version control system checkout')
-    state = Attribute('Persistent state')
-    
-    def sync(revision_nr, message=''):
-        """Synchronize persistent Python state with version control system.
+    root = Attribute('The root container')
 
-        revision_nr - Revision number since when we want to synchronize.
-             Revision number are assumed to increment over time as new
-             revisions are made (through synchronisation). It is
-             possible to identify changes to both the checkout as well
-             as the ZODB by this revision number.  Normally a version
-             control system such as SVN controls these.
-        message - message to commit any version control changes.
+    def objects(revision_nr):
+        """Objects modified/added in state since revision_nr.
 
-        Returns a ISynchronizationInfo object with a report of the
-        synchronization, including the new revision number after 
-        synchronization.
+        Ideally, only those objects that have been modified or added
+        since the synchronisation marked by revision_nr should be
+        returned. Returning more objects (as long as they exist) is
+        safe, however, though less efficient.
         """
-        
-    def save(revision_nr):
-        """Save state to filesystem location of checkout.
 
-        revision_nr - revision_nr since when there have been state changes.
-        """
+    def removed(revision_nr):
+        """Paths removed since revision_nr.
 
-    def load(revision_nr):
-        """Load the filesystem information into persistent state.
+        The path is a path from the state root object to the actual
+        object that was removed. It is therefore not the same as the
+        physically locatable path. These paths always use the forward
+        slash as the seperator, and thus are not subject to os.path.sep
+        like filesystem paths are.
 
-        revision_nr - revision_nr after which to look for filesystem changes.
+        Ideally, only those paths that have been removed since the
+        synchronisation marked by revision_nr should be returned. It
+        is safe to return paths that were added again later, so it is
+        safe to return paths of objects returned by the 'objects'
+        method.
         """
-    
+
 class ICheckout(Interface):
     """A version control system checkout.
+
+    Implement this for our version control system. A version for
+    SVN has been implemented in z3c.vcsync.svn
     """        
     path = Attribute('Path to checkout root')
 
@@ -100,34 +101,43 @@
         Returns filesystem (py) paths to files that were removed.
         """
 
-class IState(Interface):
-    """Information about Python object state.
+class ISynchronizer(Interface):
+    """Synchronizer between state and version control.
+
+    This object needs to have a 'checkout' attribute (that implements
+    ICheckout) and a 'state' attribute (that implements IState).
+
+    The 'sync' method drives the synchronization. 
     """
-    root = Attribute('The root container')
+    checkout = Attribute('Version control system checkout')
+    state = Attribute('Persistent state')
+    
+    def sync(revision_nr, message=''):
+        """Synchronize persistent Python state with version control system.
 
-    def objects(revision_nr):
-        """Objects modified/added in state since revision_nr.
+        revision_nr - Revision number since when we want to synchronize.
+             Revision number are assumed to increment over time as new
+             revisions are made (through synchronisation). It is
+             possible to identify changes to both the checkout as well
+             as the ZODB by this revision number.  Normally a version
+             control system such as SVN controls these.
+        message - message to commit any version control changes.
 
-        Ideally, only those objects that have been modified or added
-        since the synchronisation marked by revision_nr should be
-        returned. Returning more objects (as long as they exist) is
-        safe, however, though less efficient.
+        Returns a ISynchronizationInfo object with a report of the
+        synchronization, including the new revision number after 
+        synchronization.
         """
+        
+    def save(revision_nr):
+        """Save state to filesystem location of checkout.
 
-    def removed(revision_nr):
-        """Paths removed since revision_nr.
+        revision_nr - revision_nr since when there have been state changes.
+        """
 
-        The path is a path from the state root object to the actual
-        object that was removed. It is therefore not the same as the
-        physically locatable path. These paths always use the forward
-        slash as the seperator, and thus are not subject to os.path.sep
-        like filesystem paths are.
+    def load(revision_nr):
+        """Load the filesystem information into persistent state.
 
-        Ideally, only those paths that have been removed since the
-        synchronisation marked by revision_nr should be returned. It
-        is safe to return paths that were added again later, so it is
-        safe to return paths of objects returned by the 'objects'
-        method.
+        revision_nr - revision_nr after which to look for filesystem changes.
         """
 
 class ISynchronizationInfo(Interface):
@@ -162,3 +172,17 @@
 
         The paths are filesystem paths (py.path objects)
         """
+
+class IVcDump(Interface):
+    def save(checkout, path):
+        """Save context object to path in checkout.
+
+        checkout - an ICheckout object
+        path - a py.path object referring to directory to save in.
+
+        This might result in the creation of a new file or directory under
+        the path, or alternatively to the modification of an existing file
+        or directory.
+
+        Returns the path just created.
+        """

Modified: z3c.vcsync/trunk/src/z3c/vcsync/svn.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/svn.py	2008-03-11 16:12:34 UTC (rev 84581)
+++ z3c.vcsync/trunk/src/z3c/vcsync/svn.py	2008-03-11 17:45:19 UTC (rev 84582)
@@ -1,12 +1,17 @@
+import grok
+
 import py
 from datetime import datetime
 
+from z3c.vcsync.interfaces import ICheckout
+
 class SvnCheckout(object):
     """A checkout for SVN.
 
     It is assumed to be initialized with py.path.svnwc
     """
-
+    grok.implements(ICheckout)
+    
     def __init__(self, path):
         self.path = path
         self._files = set()



More information about the Checkins mailing list