[Checkins] SVN: z3c.vcsync/trunk/ Get rid of 'Vc' in IVcFactory and IVcDump. Also remark on API updates

Martijn Faassen faassen at infrae.com
Wed Apr 23 09:24:41 EDT 2008


Log message for revision 85638:
  Get rid of 'Vc' in IVcFactory and IVcDump. Also remark on API updates
  in CHANGES.txt.
  

Changed:
  U   z3c.vcsync/trunk/CHANGES.txt
  U   z3c.vcsync/trunk/src/z3c/vcsync/README.txt
  U   z3c.vcsync/trunk/src/z3c/vcsync/importexport.py
  U   z3c.vcsync/trunk/src/z3c/vcsync/importexport.txt
  U   z3c.vcsync/trunk/src/z3c/vcsync/interfaces.py
  U   z3c.vcsync/trunk/src/z3c/vcsync/internal.txt
  U   z3c.vcsync/trunk/src/z3c/vcsync/tests.py
  U   z3c.vcsync/trunk/src/z3c/vcsync/vc.py

-=-
Modified: z3c.vcsync/trunk/CHANGES.txt
===================================================================
--- z3c.vcsync/trunk/CHANGES.txt	2008-04-23 13:08:07 UTC (rev 85637)
+++ z3c.vcsync/trunk/CHANGES.txt	2008-04-23 13:24:41 UTC (rev 85638)
@@ -7,12 +7,24 @@
 Features added
 ~~~~~~~~~~~~~~
 
+* The API has been cleaned up and revised. This will break code that
+  uses this library, but so far I don't think that is many people
+  yet. :)
+
+* A major refactoring of the tests, including real SVN tests. This
+  requires SVN to be installed on the system where the tests are being
+  run, including the ``svn-admin`` command.
+
+* ``IState`` objects now need to implement methods to access and
+  maintain the revision number of the last revision.
+
 * The developer must now also implement ``IParser`` utilities for
-  files that can be synchronized (besides ``IVcFactory``. The
-  ``IParser`` utility overwrites the existing object instead of
-  creating a new one. This allows synchronization to be a bit nicer
-  and not remove and recreate objects unnecessarily, which makes it
-  harder to implement things like references between objects.
+  files that can be synchronized (besides ``IFactory``, which used to
+  be called ``IVcFactory``. The ``IParser`` utility overwrites the
+  existing object instead of creating a new one. This allows
+  synchronization to be a bit nicer and not remove and recreate
+  objects unnecessarily, which makes it harder to implement things
+  like references between objects.
 
 * Add a facility to pass a special function along that is called for
   all objects created or modified during the synchronization (or

Modified: z3c.vcsync/trunk/src/z3c/vcsync/README.txt
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/README.txt	2008-04-23 13:08:07 UTC (rev 85637)
+++ z3c.vcsync/trunk/src/z3c/vcsync/README.txt	2008-04-23 13:24:41 UTC (rev 85638)
@@ -209,10 +209,10 @@
 and we need to add it. To do this we implement a factory (where we use
 the parser for the real work)::
 
-  >>> from z3c.vcsync.interfaces import IVcFactory
+  >>> from z3c.vcsync.interfaces import IFactory
   >>> from zope import component
   >>> class ItemFactory(grok.GlobalUtility):
-  ...   grok.provides(IVcFactory)
+  ...   grok.provides(IFactory)
   ...   grok.name('.test')
   ...   def __call__(self, path):
   ...       parser = component.getUtility(IParser, '.test')
@@ -242,7 +242,7 @@
   ...         pass
 
   >>> class ContainerFactory(grok.GlobalUtility):
-  ...     grok.provides(IVcFactory)
+  ...     grok.provides(IFactory)
   ...     def __call__(self, path):
   ...         return Container()
 

Modified: z3c.vcsync/trunk/src/z3c/vcsync/importexport.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/importexport.py	2008-04-23 13:08:07 UTC (rev 85637)
+++ z3c.vcsync/trunk/src/z3c/vcsync/importexport.py	2008-04-23 13:24:41 UTC (rev 85638)
@@ -2,12 +2,12 @@
 import tempfile, zipfile
 
 from zope.app.container.interfaces import IContainer
-from z3c.vcsync.interfaces import IVcDump, IVcFactory
+from z3c.vcsync.interfaces import IDump, IFactory
 from zope.component import getUtility
     
 def export(root, path):
     for obj in root.values():
-        IVcDump(obj).save(path)
+        IDump(obj).save(path)
         if IContainer.providedBy(obj):
             export(obj, path.join(obj.__name__))
 
@@ -40,7 +40,7 @@
 def _import_helper(obj, path):
     modified_objects = []
     for p in path.listdir():
-        factory = getUtility(IVcFactory, name=p.ext)
+        factory = getUtility(IFactory, name=p.ext)
         name = p.purebasename
         if name not in obj:
             obj[name] = new_obj = factory(p)

Modified: z3c.vcsync/trunk/src/z3c/vcsync/importexport.txt
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/importexport.txt	2008-04-23 13:08:07 UTC (rev 85637)
+++ z3c.vcsync/trunk/src/z3c/vcsync/importexport.txt	2008-04-23 13:24:41 UTC (rev 85638)
@@ -120,9 +120,9 @@
 
 The factory to create the item::
 
-  >>> from z3c.vcsync.interfaces import IVcFactory
+  >>> from z3c.vcsync.interfaces import IFactory
   >>> class ItemFactory(grok.GlobalUtility):
-  ...   grok.provides(IVcFactory)
+  ...   grok.provides(IFactory)
   ...   grok.name('.test')
   ...   def __call__(self, path):
   ...       payload = int(path.read())
@@ -133,7 +133,7 @@
 The factory to create the container::
 
   >>> class ContainerFactory(grok.GlobalUtility):
-  ...   grok.provides(IVcFactory)
+  ...   grok.provides(IFactory)
   ...   def __call__(self, path):
   ...       return Container()
   >>> grok.testing.grok_component('ContainerFactory', ContainerFactory)

Modified: z3c.vcsync/trunk/src/z3c/vcsync/interfaces.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/interfaces.py	2008-04-23 13:08:07 UTC (rev 85637)
+++ z3c.vcsync/trunk/src/z3c/vcsync/interfaces.py	2008-04-23 13:24:41 UTC (rev 85638)
@@ -29,7 +29,7 @@
         path - the path to update from
         """
 
-class IVcFactory(Interface):
+class IFactory(Interface):
     """Load object from the filesystem into a new object.
 
     Implement this interface as a (global) utility, registered with
@@ -211,7 +211,12 @@
         The paths are filesystem paths (py.path objects)
         """
 
-class IVcDump(Interface):
+class IDump(Interface):
+    """Dump an object to the filesystem.
+
+    Usually there should be no need to implement this interface in your
+    application.
+    """
     def save(checkout, path):
         """Save context object to path in checkout.
 

Modified: z3c.vcsync/trunk/src/z3c/vcsync/internal.txt
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/internal.txt	2008-04-23 13:08:07 UTC (rev 85637)
+++ z3c.vcsync/trunk/src/z3c/vcsync/internal.txt	2008-04-23 13:24:41 UTC (rev 85638)
@@ -320,10 +320,10 @@
 To have the ability to create new objects, a factory is registered for
 the ``.test`` extension as well, implemented in terms of ``ItemParser``::
 
-  >>> from z3c.vcsync.interfaces import IVcFactory
+  >>> from z3c.vcsync.interfaces import IFactory
   >>> from zope import component
   >>> class ItemFactory(grok.GlobalUtility):
-  ...   grok.provides(IVcFactory)
+  ...   grok.provides(IFactory)
   ...   grok.name('.test')
   ...   def __call__(self, path):
   ...       parser = component.getUtility(IParser, '.test')
@@ -348,7 +348,7 @@
 the use of ``IParser`` here, but we won't do this for consistency::
 
   >>> class ContainerFactory(grok.GlobalUtility):
-  ...   grok.provides(IVcFactory)
+  ...   grok.provides(IFactory)
   ...   def __call__(self, path):
   ...       parser = component.getUtility(IParser, '')
   ...       container = Container()
@@ -626,7 +626,7 @@
   >>> grok.testing.grok_component('Item2Parser', Item2Parser)
   True 
   >>> class Item2Factory(grok.GlobalUtility):
-  ...   grok.provides(IVcFactory)
+  ...   grok.provides(IFactory)
   ...   grok.name('.test2')
   ...   def __call__(self, path):
   ...       parser = component.getUtility(IParser, '.test2')

Modified: z3c.vcsync/trunk/src/z3c/vcsync/tests.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/tests.py	2008-04-23 13:08:07 UTC (rev 85637)
+++ z3c.vcsync/trunk/src/z3c/vcsync/tests.py	2008-04-23 13:24:41 UTC (rev 85638)
@@ -11,7 +11,7 @@
 from zope.app.container.interfaces import IContainer
 from zope.exceptions.interfaces import DuplicationError
 
-from z3c.vcsync.interfaces import (ISerializer, IVcDump, IVcFactory,
+from z3c.vcsync.interfaces import (ISerializer, IDump, IFactory,
                                    IState, ICheckout)
 from z3c.vcsync import vc
 

Modified: z3c.vcsync/trunk/src/z3c/vcsync/vc.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/vc.py	2008-04-23 13:08:07 UTC (rev 85637)
+++ z3c.vcsync/trunk/src/z3c/vcsync/vc.py	2008-04-23 13:24:41 UTC (rev 85638)
@@ -7,18 +7,18 @@
 from zope.app.container.interfaces import IContainer
 from zope.traversing.interfaces import IPhysicallyLocatable
 
-from z3c.vcsync.interfaces import (IVcDump, ISerializer, IParser,
-                                   IState, IVcFactory, ISynchronizer,
+from z3c.vcsync.interfaces import (IDump, ISerializer, IParser,
+                                   IState, IFactory, ISynchronizer,
                                    ISynchronizationInfo)
 
 import grok
 
-class VcDump(grok.Adapter):
-    """General VcDump for arbitrary objects.
+class Dump(grok.Adapter):
+    """General dump for arbitrary objects.
 
     Can be overridden for specific objects (such as containers).
     """
-    grok.provides(IVcDump)
+    grok.provides(IDump)
     grok.context(Interface)
 
     def save(self, path):
@@ -30,8 +30,8 @@
         f.close()
         return path
     
-class ContainerVcDump(grok.Adapter):
-    grok.provides(IVcDump)
+class ContainerDump(grok.Adapter):
+    grok.provides(IDump)
     grok.context(IContainer)
         
     def save(self, path):
@@ -182,7 +182,7 @@
         # now save all files that have been modified/added
         root = self.state.root
         for obj in self.state.objects(revision_nr):
-            IVcDump(obj).save(self._get_container_path(root, obj))
+            IDump(obj).save(self._get_container_path(root, obj))
 
     def load(self, revision_nr):
         # remove all objects that have been removed in the checkout
@@ -219,7 +219,7 @@
                 parser = getUtility(IParser, name=ext)
                 parser(container[name], file_path)
             else:
-                factory = getUtility(IVcFactory, name=ext)
+                factory = getUtility(IFactory, name=ext)
                 container[name] = factory(file_path)
             modified_objects.append(container[name])
         return modified_objects



More information about the Checkins mailing list