[Checkins] SVN: zc.sourcefactory/trunk/ Merge changes from 0.3.3 release

Christian Theune ct at gocept.com
Tue Jun 10 11:11:23 EDT 2008


Log message for revision 87295:
  Merge changes from 0.3.3 release
  

Changed:
  U   zc.sourcefactory/trunk/CHANGES.txt
  A   zc.sourcefactory/trunk/src/zc/sourcefactory/constructors.txt
  U   zc.sourcefactory/trunk/src/zc/sourcefactory/factories.py
  U   zc.sourcefactory/trunk/src/zc/sourcefactory/tests.py

-=-
Modified: zc.sourcefactory/trunk/CHANGES.txt
===================================================================
--- zc.sourcefactory/trunk/CHANGES.txt	2008-06-10 15:08:23 UTC (rev 87294)
+++ zc.sourcefactory/trunk/CHANGES.txt	2008-06-10 15:11:22 UTC (rev 87295)
@@ -4,7 +4,13 @@
 0.4.0 (unreleased)
 ------------------
 
+0.3.3 (2008-06-10)
+------------------
 
+    - Fixed bug in __new__ of factories that would disallow subclasses to use
+      constructors that expect a different signature. (Thanks to Sebastian
+      Wehrmann for the patch.)
+
 0.3.2 (2008-04-09)
 ------------------
 

Copied: zc.sourcefactory/trunk/src/zc/sourcefactory/constructors.txt (from rev 87291, zc.sourcefactory/branches/0.3/src/zc/sourcefactory/constructors.txt)
===================================================================
--- zc.sourcefactory/trunk/src/zc/sourcefactory/constructors.txt	                        (rev 0)
+++ zc.sourcefactory/trunk/src/zc/sourcefactory/constructors.txt	2008-06-10 15:11:22 UTC (rev 87295)
@@ -0,0 +1,26 @@
+===================
+Custom constructors
+===================
+
+Source factories are intended to behave as natural as possible. A side-effect
+of using a custom factory method (__new__) on the base class is that
+sub-classes may have a hard time if their constructor (__init__) has a
+different signature.
+
+zc.sourcefactory takes extra measures to allow using a custom constructor with
+a different signature.
+
+>>> import zc.sourcefactory.basic
+
+>>> class Source(zc.sourcefactory.basic.BasicSourceFactory):
+...
+...     def __init__(self, values):
+...         super(Source, self).__init__()
+...         self.values = values
+...
+...     def getValues(self):
+...         return self.values
+
+>>> source = Source([1, 2, 3])
+>>> list(source)
+[1, 2, 3]

Modified: zc.sourcefactory/trunk/src/zc/sourcefactory/factories.py
===================================================================
--- zc.sourcefactory/trunk/src/zc/sourcefactory/factories.py	2008-06-10 15:08:23 UTC (rev 87294)
+++ zc.sourcefactory/trunk/src/zc/sourcefactory/factories.py	2008-06-10 15:11:22 UTC (rev 87295)
@@ -32,10 +32,10 @@
 
     zope.interface.implements(zc.sourcefactory.interfaces.ISourceFactory)
 
-    def __new__(cls):
+    def __new__(cls, *args, **kw):
         """Create the factory object and return source."""
         factory = object.__new__(cls)
-        factory.__init__()
+        factory.__init__(*args, **kw)
         return zc.sourcefactory.source.FactoredSource(factory)
 
 

Modified: zc.sourcefactory/trunk/src/zc/sourcefactory/tests.py
===================================================================
--- zc.sourcefactory/trunk/src/zc/sourcefactory/tests.py	2008-06-10 15:08:23 UTC (rev 87294)
+++ zc.sourcefactory/trunk/src/zc/sourcefactory/tests.py	2008-06-10 15:11:22 UTC (rev 87295)
@@ -34,6 +34,7 @@
     suite = unittest.TestSuite()
     suite.addTest(doctest.DocFileSuite('README.txt'))
     suite.addTest(doctest.DocFileSuite('mapping.txt'))
+    suite.addTest(doctest.DocFileSuite('constructors.txt'))
     adapters = FunctionalDocFileSuite('adapters.txt')
     adapters.layer = SourceFactoryLayer
     suite.addTest(adapters)



More information about the Checkins mailing list