[Checkins] SVN: z3c.blobfile/trunk/ Disabled evolution manager
which is in need of improvement.
Uwe Oestermeier
u.oestermeier at iwm-kmrc.de
Wed Feb 27 03:28:05 EST 2008
Log message for revision 84322:
Disabled evolution manager which is in need of improvement.
Changed:
U z3c.blobfile/trunk/CHANGES.txt
U z3c.blobfile/trunk/src/z3c/blobfile/blobfile.txt
U z3c.blobfile/trunk/src/z3c/blobfile/configure.zcml
-=-
Modified: z3c.blobfile/trunk/CHANGES.txt
===================================================================
--- z3c.blobfile/trunk/CHANGES.txt 2008-02-27 07:53:23 UTC (rev 84321)
+++ z3c.blobfile/trunk/CHANGES.txt 2008-02-27 08:28:05 UTC (rev 84322)
@@ -2,7 +2,7 @@
CHANGES
=======
-Version 1.0.0
--------------
+Version 0.1.0 (2008-02-27)
+--------------------------
- Initial Release
Modified: z3c.blobfile/trunk/src/z3c/blobfile/blobfile.txt
===================================================================
--- z3c.blobfile/trunk/src/z3c/blobfile/blobfile.txt 2008-02-27 07:53:23 UTC (rev 84321)
+++ z3c.blobfile/trunk/src/z3c/blobfile/blobfile.txt 2008-02-27 08:28:05 UTC (rev 84322)
@@ -5,92 +5,6 @@
of the new ZODB blob support and tries to be completely backward compatible to
the existing file implementation in zope.app.file.
-Let's assume that you have already an existing database with zope.app.file
-content types:
-
- >>> root = getRootFolder()
- >>> from zope.app.file import File, Image
-
- >>> from z3c.blobfile import testing
- >>> root[u'file'] = File('A text file', contentType='text/plain')
- >>> root[u'image'] = Image(testing.zptlogo)
-
-Since the evolve step looks for implementations of IFile we also must
-provide a way to recognize other implementations than zope.app.file.File and
-Image. Let's add a nonsense implementation as an example:
-
- >>> root[u'custom'] = testing.MyFile()
-
-Note that we cannot assume that these objects exist in isolation. Many of
-them probably are annotated, indexed, some even may be registered as utility
-etc. The evolution step throws the standard events when the objects
-are replaced and it's up the application that this replacement is recognized
-accordingly. If your application has special needs you may subscribe to the
-FileReplacedEvent.
-
-We will not test all relations to all other objects, since this is largely
-application dependent. Here we only take the ZopeDublinCore timestamps as
-an example that our evolution step leaves as many things untouched as possible.
-
- >>> from zope.dublincore.interfaces import IZopeDublinCore
- >>> import datetime
-
- >>> IZopeDublinCore(root[u'file']).created = datetime.datetime.utcnow()
- >>> t1 = IZopeDublinCore(root[u'file']).created
- >>> IZopeDublinCore(root[u'file']).title = u'No evolution'
-
-Now we perform the basic evolution steps. Since we expect some warning logs
-we need
-
- >>> from zope.testing.loggingsupport import InstalledHandler
- >>> import logging
- >>> log_handler = InstalledHandler('z3c.blobfile.generations')
-
- >>> from z3c.blobfile.generations.evolve1 import evolveZopeAppFile
- >>> evolveZopeAppFile(root)
- >>> transaction.commit()
-
- >>> for record in log_handler.records:
- ... print record.getMessage()
- Unknown ...interfaces.IFile implementation z3c.blobfile.testing.MyFile
-
-After the evolution step the class types have changed to the z3c.blobfile
-implementations:
-
- >>> import z3c.blobfile
- >>> isinstance(root[u'file'], z3c.blobfile.file.File)
- True
- >>> isinstance(root[u'image'], z3c.blobfile.image.Image)
- True
-
-Only the custom implementations remain untouched:
-
- >>> isinstance(root[u'custom'], testing.MyFile)
- True
-
-The file data remain the same ...
-
- >>> root[u'file'].data
- 'A text file'
- >>> root[u'file'].contentType
- 'text/plain'
-
- >>> root[u'image'].data == testing.zptlogo
- True
-
-and so do the annotations:
-
- >>> IZopeDublinCore(root[u'file']).created == t1
- True
- >>> IZopeDublinCore(root[u'file']).title
- u'No evolution'
-
-Even implementation details like the _data attribute still work:
-
- >>> root[u'file']._data
- 'A text file'
-
-
Compatibility with zope.app.file.File
-------------------------------------
@@ -98,6 +12,8 @@
Let's test the constructor:
+ >>> from zope.app.file import File, Image
+
>>> file = File()
>>> file.contentType
''
@@ -203,3 +119,103 @@
>>> FileWriteFile(file).write(content)
>>> file.data == content
True
+
+
+
+Evolution of Existing Files
+---------------------------
+
+Please note that the following code is experimental. The code should not be
+used in production without careful testing. Backup your Data.fs and uncomment
+the following lines in the configure.zcml if you want to replace exiting
+zope.app.file.File instances.
+
+ <utility
+ component=".generations.BlobFileSchemaManager"
+ name="z3c.blobfile"
+ />
+
+Let's assume that you have already an existing database with zope.app.file
+content types:
+
+ >>> from z3c.blobfile import testing
+ >>> root = getRootFolder()
+
+ >>> root[u'file'] = File('A text file', contentType='text/plain')
+ >>> root[u'image'] = Image(testing.zptlogo)
+
+Since the evolve step looks for implementations of IFile we also must
+provide a way to recognize other implementations than zope.app.file.File and
+Image. Let's add a nonsense implementation as an example:
+
+ >>> root[u'custom'] = testing.MyFile()
+
+Note that we cannot assume that these objects exist in isolation. Many of
+them probably are annotated, indexed, some even may be registered as utility
+etc. The evolution step throws the standard events when the objects
+are replaced and it's up the application that this replacement is recognized
+accordingly. If your application has special needs you may subscribe to the
+FileReplacedEvent.
+
+We will not test all relations to all other objects, since this is largely
+application dependent. Here we only take the ZopeDublinCore timestamps as
+an example that our evolution step leaves as many things untouched as possible.
+
+ >>> from zope.dublincore.interfaces import IZopeDublinCore
+ >>> import datetime
+
+ >>> IZopeDublinCore(root[u'file']).created = datetime.datetime.utcnow()
+ >>> t1 = IZopeDublinCore(root[u'file']).created
+ >>> IZopeDublinCore(root[u'file']).title = u'No evolution'
+
+Now we perform the basic evolution steps. Since we expect some warning logs
+we need
+
+ >>> from zope.testing.loggingsupport import InstalledHandler
+ >>> import logging
+ >>> log_handler = InstalledHandler('z3c.blobfile.generations')
+
+ >>> from z3c.blobfile.generations.evolve1 import evolveZopeAppFile
+ >>> evolveZopeAppFile(root)
+ >>> transaction.commit()
+
+ >>> for record in log_handler.records:
+ ... print record.getMessage()
+ Unknown ...interfaces.IFile implementation z3c.blobfile.testing.MyFile
+
+After the evolution step the class types have changed to the z3c.blobfile
+implementations:
+
+ >>> import z3c.blobfile
+ >>> isinstance(root[u'file'], z3c.blobfile.file.File)
+ True
+ >>> isinstance(root[u'image'], z3c.blobfile.image.Image)
+ True
+
+Only the custom implementations remain untouched:
+
+ >>> isinstance(root[u'custom'], testing.MyFile)
+ True
+
+The file data remain the same ...
+
+ >>> root[u'file'].data
+ 'A text file'
+ >>> root[u'file'].contentType
+ 'text/plain'
+
+ >>> root[u'image'].data == testing.zptlogo
+ True
+
+and so do the annotations:
+
+ >>> IZopeDublinCore(root[u'file']).created == t1
+ True
+ >>> IZopeDublinCore(root[u'file']).title
+ u'No evolution'
+
+Even implementation details like the _data attribute still work:
+
+ >>> root[u'file']._data
+ 'A text file'
+
Modified: z3c.blobfile/trunk/src/z3c/blobfile/configure.zcml
===================================================================
--- z3c.blobfile/trunk/src/z3c/blobfile/configure.zcml 2008-02-27 07:53:23 UTC (rev 84321)
+++ z3c.blobfile/trunk/src/z3c/blobfile/configure.zcml 2008-02-27 08:28:05 UTC (rev 84322)
@@ -44,11 +44,14 @@
/>
</class>
+ <!-- TODO: Improve schema manager
+
<utility
component=".generations.BlobFileSchemaManager"
name="z3c.blobfile"
/>
+ -->
<!-- `IStorage` utilities should be named with the dotted name
referencing the implementation.
More information about the Checkins
mailing list