[Zope-Checkins] SVN: Zope/branches/2.9/ fix for #2235: ZCatalog triggering boolean evaluation of objects

2006-11-15 Thread Leonardo Rochael Almeida
Log message for revision 71132:
  fix for #2235: ZCatalog triggering boolean evaluation of objects
  

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt
  U   Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py
  U   Zope/branches/2.9/lib/python/Products/ZCatalog/tests/testCatalog.py

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===
--- Zope/branches/2.9/doc/CHANGES.txt   2006-11-15 08:00:29 UTC (rev 71131)
+++ Zope/branches/2.9/doc/CHANGES.txt   2006-11-15 08:05:34 UTC (rev 71132)
@@ -9,6 +9,11 @@
 
Bugs fixed
 
+  - Collector #2235: A number of ZCatalog methods were doing boolean
+evaluation of objects that implemented __len__ instead of checking
+them against None. Replaced a number of if not obj with
+if obj is not None.
+
   - Collector #2218: fixed wrong logger argument in OFS/Cache.py
 
   - Collector #2205: fixed wrong logger argument in ZRDB/Connection.py

Modified: Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py
===
--- Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py  2006-11-15 
08:00:29 UTC (rev 71131)
+++ Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py  2006-11-15 
08:05:34 UTC (rev 71132)
@@ -234,7 +234,7 @@
 
 for url in urls:
 obj = self.resolve_path(url)
-if not obj and hasattr(self, 'REQUEST'):
+if obj is None and hasattr(self, 'REQUEST'):
 obj = self.resolve_url(url, REQUEST)
 if obj is not None:
 self.catalog_object(obj, url)
@@ -298,7 +298,7 @@
 
 p = paths[i]
 obj = self.resolve_path(p)
-if not obj:
+if obj is None:
 obj = self.resolve_url(p, self.REQUEST)
 if obj is not None:
 try:
@@ -615,8 +615,8 @@
 def getobject(self, rid, REQUEST=None):
 Return a cataloged object given a 'data_record_id_'
 
-obj = self.aq_parent.unrestrictedTraverse(self.getpath(rid))
-if not obj:
+obj = self.aq_parent.unrestrictedTraverse(self.getpath(rid), None)
+if obj is None:
 if REQUEST is None:
 REQUEST=self.REQUEST
 obj = self.resolve_url(self.getpath(rid), REQUEST)

Modified: Zope/branches/2.9/lib/python/Products/ZCatalog/tests/testCatalog.py
===
--- Zope/branches/2.9/lib/python/Products/ZCatalog/tests/testCatalog.py 
2006-11-15 08:00:29 UTC (rev 71131)
+++ Zope/branches/2.9/lib/python/Products/ZCatalog/tests/testCatalog.py 
2006-11-15 08:05:34 UTC (rev 71132)
@@ -28,6 +28,7 @@
 from AccessControl.SecurityManagement import setSecurityManager
 from AccessControl.SecurityManagement import noSecurityManager
 from AccessControl import Unauthorized
+from Acquisition import Implicit
 from Products.ZCatalog import Vocabulary
 from Products.ZCatalog.Catalog import Catalog
 from Products.ZCatalog.Catalog import CatalogError
@@ -159,7 +160,32 @@
 def __nonzero__(self):
 return False
 
+# make objects with failing __len__ and __nonzero__
+class dummyLenFail(zdummy):
+def __init__(self, num, fail):
+zdummy.__init__(self, num)
+self.fail = fail
 
+def __len__(self):
+self.fail(__len__() was called)
+
+class dummyNonzeroFail(zdummy):
+def __init__(self, num, fail):
+zdummy.__init__(self, num)
+self.fail = fail
+
+def __nonzero__(self):
+self.fail(__nonzero__() was called)
+
+class fakeparent(Implicit):
+# fake parent mapping unrestrictedTraverse to
+# catalog.resolve_path as simulated by TestZCatalog
+def __init__(self, d):
+self.d = d
+
+def unrestrictedTraverse(self, path, default=None):
+return self.d.get(path, default)
+
 class TestZCatalog(unittest.TestCase):
 
 def setUp(self):
@@ -246,7 +272,30 @@
 result = self._catalog(title='')
 self.assertEquals(1, len(result))
 
+def testBooleanEvalOn_manage_catalogObject(self):
+self.d['11'] = dummyLenFail(11, self.fail)
+self.d['12'] = dummyNonzeroFail(12, self.fail)
+# create a fake response that doesn't bomb on manage_catalogObject()
+class myresponse:
+def redirect(self, url):
+pass
+# this next call should not fail
+self._catalog.manage_catalogObject(None, myresponse(), 'URL1', 
urls=('11', '12'))
 
+def testBooleanEvalOn_refreshCatalog_getobject(self):
+# wrap catalog under the fake parent
+catalog = self._catalog.__of__(fakeparent(self.d))
+# replace entries to test refreshCatalog
+self.d['0'] = dummyLenFail(0, self.fail)
+self.d['1'] = dummyNonzeroFail(1, self.fail)
+# this next call should not fail
+catalog.refreshCatalog()
+
+ 

[Zope-Checkins] SVN: Zope/branches/2.9/doc/CHANGES.txt typo in CHANGES.txt

2006-11-15 Thread Leonardo Rochael Almeida
Log message for revision 71133:
  typo in CHANGES.txt
  

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===
--- Zope/branches/2.9/doc/CHANGES.txt   2006-11-15 08:05:34 UTC (rev 71132)
+++ Zope/branches/2.9/doc/CHANGES.txt   2006-11-15 09:06:14 UTC (rev 71133)
@@ -12,7 +12,7 @@
   - Collector #2235: A number of ZCatalog methods were doing boolean
 evaluation of objects that implemented __len__ instead of checking
 them against None. Replaced a number of if not obj with
-if obj is not None.
+if obj is None.
 
   - Collector #2218: fixed wrong logger argument in OFS/Cache.py
 

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/branches/2.10/ fix for #2235: ZCatalog triggering boolean evaluation of objects

2006-11-15 Thread Leonardo Rochael Almeida
Log message for revision 71135:
  fix for #2235: ZCatalog triggering boolean evaluation of objects
  

Changed:
  U   Zope/branches/2.10/doc/CHANGES.txt
  U   Zope/branches/2.10/lib/python/Products/ZCatalog/ZCatalog.py
  U   Zope/branches/2.10/lib/python/Products/ZCatalog/tests/testCatalog.py

-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===
--- Zope/branches/2.10/doc/CHANGES.txt  2006-11-15 09:07:54 UTC (rev 71134)
+++ Zope/branches/2.10/doc/CHANGES.txt  2006-11-15 09:19:33 UTC (rev 71135)
@@ -12,6 +12,11 @@
 
   - Collector #2213: Can't edit old ZopePageTemplate instances.
 
+  - Collector #2235: A number of ZCatalog methods were doing boolean
+evaluation of objects that implemented __len__ instead of checking
+them against None. Replaced a number of if not obj with
+if obj is None.
+
   - Collector #2208: rewriting/setting the 'charset' part of the
 content-type HTTP header will be done only for 'text/*'
 

Modified: Zope/branches/2.10/lib/python/Products/ZCatalog/ZCatalog.py
===
--- Zope/branches/2.10/lib/python/Products/ZCatalog/ZCatalog.py 2006-11-15 
09:07:54 UTC (rev 71134)
+++ Zope/branches/2.10/lib/python/Products/ZCatalog/ZCatalog.py 2006-11-15 
09:19:33 UTC (rev 71135)
@@ -221,7 +221,7 @@
 
 for url in urls:
 obj = self.resolve_path(url)
-if not obj and hasattr(self, 'REQUEST'):
+if obj is None and hasattr(self, 'REQUEST'):
 obj = self.resolve_url(url, REQUEST)
 if obj is not None:
 self.catalog_object(obj, url)
@@ -289,7 +289,7 @@
 
 p = paths[i]
 obj = self.resolve_path(p)
-if not obj:
+if obj is None:
 obj = self.resolve_url(p, self.REQUEST)
 if obj is not None:
 try:
@@ -587,8 +587,8 @@
 def getobject(self, rid, REQUEST=None):
 Return a cataloged object given a 'data_record_id_'
 
-obj = self.aq_parent.unrestrictedTraverse(self.getpath(rid))
-if not obj:
+obj = self.aq_parent.unrestrictedTraverse(self.getpath(rid), None)
+if obj is None:
 if REQUEST is None:
 REQUEST=self.REQUEST
 obj = self.resolve_url(self.getpath(rid), REQUEST)

Modified: Zope/branches/2.10/lib/python/Products/ZCatalog/tests/testCatalog.py
===
--- Zope/branches/2.10/lib/python/Products/ZCatalog/tests/testCatalog.py
2006-11-15 09:07:54 UTC (rev 71134)
+++ Zope/branches/2.10/lib/python/Products/ZCatalog/tests/testCatalog.py
2006-11-15 09:19:33 UTC (rev 71135)
@@ -28,6 +28,7 @@
 from AccessControl.SecurityManagement import setSecurityManager
 from AccessControl.SecurityManagement import noSecurityManager
 from AccessControl import Unauthorized
+from Acquisition import Implicit
 from Products.ZCatalog import Vocabulary
 from Products.ZCatalog.Catalog import Catalog
 from Products.ZCatalog.Catalog import CatalogError
@@ -159,7 +160,32 @@
 def __nonzero__(self):
 return False
 
+# make objects with failing __len__ and __nonzero__
+class dummyLenFail(zdummy):
+def __init__(self, num, fail):
+zdummy.__init__(self, num)
+self.fail = fail
 
+def __len__(self):
+self.fail(__len__() was called)
+
+class dummyNonzeroFail(zdummy):
+def __init__(self, num, fail):
+zdummy.__init__(self, num)
+self.fail = fail
+
+def __nonzero__(self):
+self.fail(__nonzero__() was called)
+
+class fakeparent(Implicit):
+# fake parent mapping unrestrictedTraverse to
+# catalog.resolve_path as simulated by TestZCatalog
+def __init__(self, d):
+self.d = d
+
+def unrestrictedTraverse(self, path, default=None):
+return self.d.get(path, default)
+
 class TestZCatalog(unittest.TestCase):
 
 def setUp(self):
@@ -246,7 +272,30 @@
 result = self._catalog(title='')
 self.assertEquals(1, len(result))
 
+def testBooleanEvalOn_manage_catalogObject(self):
+self.d['11'] = dummyLenFail(11, self.fail)
+self.d['12'] = dummyNonzeroFail(12, self.fail)
+# create a fake response that doesn't bomb on manage_catalogObject()
+class myresponse:
+def redirect(self, url):
+pass
+# this next call should not fail
+self._catalog.manage_catalogObject(None, myresponse(), 'URL1', 
urls=('11', '12'))
 
+def testBooleanEvalOn_refreshCatalog_getobject(self):
+# wrap catalog under the fake parent
+catalog = self._catalog.__of__(fakeparent(self.d))
+# replace entries to test refreshCatalog
+self.d['0'] = dummyLenFail(0, self.fail)
+self.d['1'] = dummyNonzeroFail(1, self.fail)
+# this next 

[Zope-Checkins] SVN: Zope/trunk/ fix for #2235: ZCatalog triggering boolean evaluation of objects

2006-11-15 Thread Leonardo Rochael Almeida
Log message for revision 71136:
  fix for #2235: ZCatalog triggering boolean evaluation of objects
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py
  U   Zope/trunk/lib/python/Products/ZCatalog/tests/testCatalog.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===
--- Zope/trunk/doc/CHANGES.txt  2006-11-15 09:19:33 UTC (rev 71135)
+++ Zope/trunk/doc/CHANGES.txt  2006-11-15 09:26:18 UTC (rev 71136)
@@ -13,6 +13,11 @@
 
   - Collector #2213: Can't edit old ZopePageTemplate instances.
 
+  - Collector #2235: A number of ZCatalog methods were doing boolean
+evaluation of objects that implemented __len__ instead of checking
+them against None. Replaced a number of if not obj with
+if obj is None.
+
   - reStructuredText/ZReST: setting raw_enabled to 0 for security
 reasons
 

Modified: Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py
===
--- Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py 2006-11-15 09:19:33 UTC 
(rev 71135)
+++ Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py 2006-11-15 09:26:18 UTC 
(rev 71136)
@@ -221,7 +221,7 @@
 
 for url in urls:
 obj = self.resolve_path(url)
-if not obj and hasattr(self, 'REQUEST'):
+if obj is None and hasattr(self, 'REQUEST'):
 obj = self.resolve_url(url, REQUEST)
 if obj is not None:
 self.catalog_object(obj, url)
@@ -289,7 +289,7 @@
 
 p = paths[i]
 obj = self.resolve_path(p)
-if not obj:
+if obj is None:
 obj = self.resolve_url(p, self.REQUEST)
 if obj is not None:
 try:
@@ -587,8 +587,8 @@
 def getobject(self, rid, REQUEST=None):
 Return a cataloged object given a 'data_record_id_'
 
-obj = self.aq_parent.unrestrictedTraverse(self.getpath(rid))
-if not obj:
+obj = self.aq_parent.unrestrictedTraverse(self.getpath(rid), None)
+if obj is None:
 if REQUEST is None:
 REQUEST=self.REQUEST
 obj = self.resolve_url(self.getpath(rid), REQUEST)

Modified: Zope/trunk/lib/python/Products/ZCatalog/tests/testCatalog.py
===
--- Zope/trunk/lib/python/Products/ZCatalog/tests/testCatalog.py
2006-11-15 09:19:33 UTC (rev 71135)
+++ Zope/trunk/lib/python/Products/ZCatalog/tests/testCatalog.py
2006-11-15 09:26:18 UTC (rev 71136)
@@ -28,6 +28,7 @@
 from AccessControl.SecurityManagement import setSecurityManager
 from AccessControl.SecurityManagement import noSecurityManager
 from AccessControl import Unauthorized
+from Acquisition import Implicit
 from Products.ZCatalog import Vocabulary
 from Products.ZCatalog.Catalog import Catalog
 from Products.ZCatalog.Catalog import CatalogError
@@ -159,7 +160,32 @@
 def __nonzero__(self):
 return False
 
+# make objects with failing __len__ and __nonzero__
+class dummyLenFail(zdummy):
+def __init__(self, num, fail):
+zdummy.__init__(self, num)
+self.fail = fail
 
+def __len__(self):
+self.fail(__len__() was called)
+
+class dummyNonzeroFail(zdummy):
+def __init__(self, num, fail):
+zdummy.__init__(self, num)
+self.fail = fail
+
+def __nonzero__(self):
+self.fail(__nonzero__() was called)
+
+class fakeparent(Implicit):
+# fake parent mapping unrestrictedTraverse to
+# catalog.resolve_path as simulated by TestZCatalog
+def __init__(self, d):
+self.d = d
+
+def unrestrictedTraverse(self, path, default=None):
+return self.d.get(path, default)
+
 class TestZCatalog(unittest.TestCase):
 
 def setUp(self):
@@ -246,7 +272,30 @@
 result = self._catalog(title='')
 self.assertEquals(1, len(result))
 
+def testBooleanEvalOn_manage_catalogObject(self):
+self.d['11'] = dummyLenFail(11, self.fail)
+self.d['12'] = dummyNonzeroFail(12, self.fail)
+# create a fake response that doesn't bomb on manage_catalogObject()
+class myresponse:
+def redirect(self, url):
+pass
+# this next call should not fail
+self._catalog.manage_catalogObject(None, myresponse(), 'URL1', 
urls=('11', '12'))
 
+def testBooleanEvalOn_refreshCatalog_getobject(self):
+# wrap catalog under the fake parent
+catalog = self._catalog.__of__(fakeparent(self.d))
+# replace entries to test refreshCatalog
+self.d['0'] = dummyLenFail(0, self.fail)
+self.d['1'] = dummyNonzeroFail(1, self.fail)
+# this next call should not fail
+catalog.refreshCatalog()
+
+for uid in ('0', '1'):
+rid = self._catalog.getrid(uid)
+

[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/ Collector #2237: 'make' gave bad directions for inplace usage.

2006-11-15 Thread Tres Seaver
Log message for revision 71138:
  Collector #2237:  'make' gave bad directions for inplace usage.

Changed:
  U   Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
  U   Zope/branches/Zope-2_8-branch/inst/Makefile.in

-=-
Modified: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
===
--- Zope/branches/Zope-2_8-branch/doc/CHANGES.txt   2006-11-15 11:38:59 UTC 
(rev 71137)
+++ Zope/branches/Zope-2_8-branch/doc/CHANGES.txt   2006-11-15 20:32:17 UTC 
(rev 71138)
@@ -8,6 +8,9 @@
 
 Bugs fixed
 
+  - Collector #2237: 'make' doesn't tell you to run 'make inplace'
+before running 'make instance'.
+
   - Collector #2235: A number of ZCatalog methods were doing boolean
 evaluation of objects that implemented __len__ instead of checking
 them against None. Replaced a number of if not obj with

Modified: Zope/branches/Zope-2_8-branch/inst/Makefile.in
===
--- Zope/branches/Zope-2_8-branch/inst/Makefile.in  2006-11-15 11:38:59 UTC 
(rev 71137)
+++ Zope/branches/Zope-2_8-branch/inst/Makefile.in  2006-11-15 20:32:17 UTC 
(rev 71138)
@@ -38,9 +38,9 @@
 # default: The default step (invoked when make is called without a target)
 default: build
@echo
-   @echo Zope built.  Next, do \'make install\' \(or \'make instance\'
-   @echo to run a Zope instance directly from the build directory\).
-   @echo
+   @echo Zope built.  Next, do \'make install\' \(or \'make inplace\',
+   @echo followed by \'make instance\' to run a Zope instance directly
+   @echo from the build directory\).
 
 # build:   Do whatever 'setup.py build' implies
 build:

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/branches/2.9/ Forward-port fix for #2237 from 2.8 branch.

2006-11-15 Thread Tres Seaver
Log message for revision 71139:
  Forward-port fix for #2237 from 2.8 branch.

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt
  U   Zope/branches/2.9/inst/Makefile.in

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===
--- Zope/branches/2.9/doc/CHANGES.txt   2006-11-15 20:32:17 UTC (rev 71138)
+++ Zope/branches/2.9/doc/CHANGES.txt   2006-11-15 20:37:54 UTC (rev 71139)
@@ -9,6 +9,9 @@
 
Bugs fixed
 
+  - Collector #2237: 'make' doesn't tell you to run 'make inplace'
+before running 'make instance'.
+
   - Collector #2235: A number of ZCatalog methods were doing boolean
 evaluation of objects that implemented __len__ instead of checking
 them against None. Replaced a number of if not obj with

Modified: Zope/branches/2.9/inst/Makefile.in
===
--- Zope/branches/2.9/inst/Makefile.in  2006-11-15 20:32:17 UTC (rev 71138)
+++ Zope/branches/2.9/inst/Makefile.in  2006-11-15 20:37:54 UTC (rev 71139)
@@ -38,9 +38,9 @@
 # default: The default step (invoked when make is called without a target)
 default: build
@echo
-   @echo Zope built.  Next, do \'make install\' \(or \'make instance\'
-   @echo to run a Zope instance directly from the build directory\).
-   @echo
+   @echo Zope built.  Next, do \'make install\' \(or \'make inplace\',
+   @echo followed by \'make instance\' to run a Zope instance directly
+   @echo from the build directory\).
 
 # build:   Do whatever 'setup.py build' implies
 build:

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/branches/2.10/ Forward-port fix for #2237 from 2.8 branch.

2006-11-15 Thread Tres Seaver
Log message for revision 71140:
  Forward-port fix for #2237 from 2.8 branch.

Changed:
  U   Zope/branches/2.10/doc/CHANGES.txt
  U   Zope/branches/2.10/inst/Makefile.in

-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===
--- Zope/branches/2.10/doc/CHANGES.txt  2006-11-15 20:37:54 UTC (rev 71139)
+++ Zope/branches/2.10/doc/CHANGES.txt  2006-11-15 20:41:11 UTC (rev 71140)
@@ -12,6 +12,9 @@
 
   - Collector #2213: Can't edit old ZopePageTemplate instances.
 
+  - Collector #2237: 'make' doesn't tell you to run 'make inplace'
+before running 'make instance'.
+
   - Collector #2235: A number of ZCatalog methods were doing boolean
 evaluation of objects that implemented __len__ instead of checking
 them against None. Replaced a number of if not obj with

Modified: Zope/branches/2.10/inst/Makefile.in
===
--- Zope/branches/2.10/inst/Makefile.in 2006-11-15 20:37:54 UTC (rev 71139)
+++ Zope/branches/2.10/inst/Makefile.in 2006-11-15 20:41:11 UTC (rev 71140)
@@ -38,9 +38,9 @@
 # default: The default step (invoked when make is called without a target)
 default: build
@echo
-   @echo Zope built.  Next, do \'make install\' \(or \'make instance\'
-   @echo to run a Zope instance directly from the build directory\).
-   @echo
+   @echo Zope built.  Next, do \'make install\' \(or \'make inplace\',
+   @echo followed by \'make instance\' to run a Zope instance directly
+   @echo from the build directory\).
 
 # build:   Do whatever 'setup.py build' implies
 build:

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins