[Zope-CVS] SVN: zversioning/trunk/ - extracted necessary code for
doc test setup from versioncontrol/README.txt
Grégoire Weber
zope.org at incept.ch
Sun Oct 10 05:26:48 EDT 2004
Log message for revision 27879:
- extracted necessary code for doc test setup from versioncontrol/README.txt
- added notes file for arbitrary notes
Changed:
A zversioning/trunk/notes.txt
A zversioning/trunk/src/versioning/tests/repository_setup.py
-=-
Added: zversioning/trunk/notes.txt
===================================================================
--- zversioning/trunk/notes.txt 2004-10-10 08:39:30 UTC (rev 27878)
+++ zversioning/trunk/notes.txt 2004-10-10 09:26:48 UTC (rev 27879)
@@ -0,0 +1,24 @@
+
+20041010_1100/gregweb
+---------------------
+
+Our default policy what is considered part of versioned object is:
+
+ - all attributes that are defined in the schema declarations
+ at the time of writing to the repository (including the
+ directly provided ones) are considered to be part of the object
+ by default.
+
+ The existing mechanism to specify exception of this rule can be
+ found in INonVersionedData
+
+ XXX How to handle annotations? The current implementation only
+ handles attributes.
+
+ - Attributes that are not part of a schema declaration are not
+ considered being part of the object all by default
+
+ There will be an mechanism to specify what attributes shall be
+ included.
+
+
\ No newline at end of file
Property changes on: zversioning/trunk/notes.txt
___________________________________________________________________
Name: svn:executable
+ *
Added: zversioning/trunk/src/versioning/tests/repository_setup.py
===================================================================
--- zversioning/trunk/src/versioning/tests/repository_setup.py 2004-10-10 08:39:30 UTC (rev 27878)
+++ zversioning/trunk/src/versioning/tests/repository_setup.py 2004-10-10 09:26:48 UTC (rev 27879)
@@ -0,0 +1,62 @@
+
+import persistent
+import zope.interface
+import zope.app.annotation.attribute
+import zope.app.annotation.interfaces
+import zope.app.traversing.interfaces
+from zope.app.versioncontrol import interfaces
+
+def buildRoot():
+ """Opens a connection to a test database and returns the root object
+ """
+ from zope.app.tests import ztapi
+ ztapi.provideAdapter(zope.app.annotation.interfaces.IAttributeAnnotatable,
+ zope.app.annotation.interfaces.IAnnotations,
+ zope.app.annotation.attribute.AttributeAnnotations)
+
+ # Now we need to create a database with an instance of our sample object
+ # to work with:
+
+ from ZODB.tests import util
+ db = util.DB()
+ connection = db.open()
+ return connection.root()
+
+def buildOldStyleRepository():
+ """Setup a zope.app.versioncontrol repository
+
+ Placing an object under version control requires an instance of an
+ `IVersionControl` object. This package provides an implementation of
+ this interface on the `Repository` class (from
+ `zope.app.versioncontrol.repository`). Only the `IVersionControl`
+ instance is responsible for providing version control operations;
+ an instance should never be asked to perform operations directly.
+ """
+ import zope.app.versioncontrol.repository
+ import zope.interface.verify
+
+ repository = zope.app.versioncontrol.repository.Repository()
+ assert zope.interface.verify.verifyObject(
+ interfaces.IVersionControl,
+ repository)
+
+ # In order to actually use version control, there must be an
+ # interaction. This is needed to allow the framework to determine the
+ # user making changes. Let's set up an interaction now. First we need a
+ # principal. For our purposes, a principal just needs to have an id:
+ class FauxPrincipal:
+ def __init__(self, id):
+ self.id = id
+ principal = FauxPrincipal('bob')
+
+ # Then we need to define an participation for the principal in the
+ # interaction:
+ class FauxParticipation:
+ interaction=None
+ def __init__(self, principal):
+ self.principal = principal
+ participation = FauxParticipation(principal)
+
+ # Finally, we can create the interaction:
+ import zope.security.management
+ zope.security.management.newInteraction(participation)
Property changes on: zversioning/trunk/src/versioning/tests/repository_setup.py
___________________________________________________________________
Name: svn:executable
+ *
More information about the Zope-CVS
mailing list