[Zope-Checkins] SVN: Zope/branches/2.12/doc/CHANGES.rst Missing changelog for the ImageFile warning

2010-07-14 Thread Leonardo Rochael Almeida
Log message for revision 114755:
  Missing changelog for the ImageFile warning

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===
--- Zope/branches/2.12/doc/CHANGES.rst  2010-07-14 15:14:17 UTC (rev 114754)
+++ Zope/branches/2.12/doc/CHANGES.rst  2010-07-14 15:15:36 UTC (rev 114755)
@@ -28,7 +28,14 @@
 - LP #143273: Enable the dtml-var modifiers url_quote, url_unquote, 
   url_quote_plus and url_unquote_plus to handle unicode strings.
 
+Features Added
+++
 
+- Warn when App.ImageFile.ImageFile receives a relative path with no prefix,
+  and then has to assume the path to be relative to software home. This
+  behaviour is deprecated as packages can be factored out to their own
+  distribution, making the software home relative path meaningless. 
+
 2.12.9 (2010-07-13)
 ---
 

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


[Zope-Checkins] SVN: Zope/branches/2.12/src/App/ Warn on App.ImageFile.ImageFile deprecated assumption of software_home

2010-07-14 Thread Leonardo Rochael Almeida
Log message for revision 114749:
  Warn on App.ImageFile.ImageFile deprecated assumption of software_home

Changed:
  U   Zope/branches/2.12/src/App/ImageFile.py
  U   Zope/branches/2.12/src/App/config.py
  A   Zope/branches/2.12/src/App/tests/testImageFile.py

-=-
Modified: Zope/branches/2.12/src/App/ImageFile.py
===
--- Zope/branches/2.12/src/App/ImageFile.py 2010-07-14 14:58:01 UTC (rev 
114748)
+++ Zope/branches/2.12/src/App/ImageFile.py 2010-07-14 15:07:11 UTC (rev 
114749)
@@ -18,6 +18,7 @@
 import os.path
 import stat
 import time
+import warnings
 
 from AccessControl.SecurityInfo import ClassSecurityInfo
 from Acquisition import Explicit
@@ -34,6 +35,13 @@
 os.path.join(os.path.dirname(Zope2.__file__), os.path.pardir)
 )
 
+NON_PREFIX_WARNING = ('Assuming image location to be present in the Zope2 '
+  'distribution. This is deprecated and might lead to ' 
+  'broken code if the directory in question is moved ' 
+  'to another distribution. Please provide either an '
+  'absolute file system path or a prefix. Support for ' 
+  'relative filenames without a prefix might be '
+  'dropped in a future Zope2 release.')
 
 class ImageFile(Explicit):
 Image objects stored in external files.
@@ -43,9 +51,12 @@
 def __init__(self, path, _prefix=None):
 import Globals  # for data
 if _prefix is None:
-_prefix=getattr(getConfiguration(), 'softwarehome', PREFIX)
+_prefix=getattr(getConfiguration(), 'softwarehome', None) or PREFIX
+if not os.path.isabs(path):
+warnings.warn(NON_PREFIX_WARNING, UserWarning, 2 )
 elif type(_prefix) is not type(''):
 _prefix=package_home(_prefix)
+# _prefix is ignored if path is absolute
 path = os.path.join(_prefix, path)
 self.path=path
 if Globals.DevelopmentMode:

Modified: Zope/branches/2.12/src/App/config.py
===
--- Zope/branches/2.12/src/App/config.py2010-07-14 14:58:01 UTC (rev 
114748)
+++ Zope/branches/2.12/src/App/config.py2010-07-14 15:07:11 UTC (rev 
114749)
@@ -36,7 +36,7 @@
 def setConfiguration(cfg):
 Set the global configuration object.
 
-Legacy sources of common configuraiton values are updated to
+Legacy sources of common configuration values are updated to
 reflect the new configuration; this may be removed in some future
 version.
 

Added: Zope/branches/2.12/src/App/tests/testImageFile.py
===
--- Zope/branches/2.12/src/App/tests/testImageFile.py   
(rev 0)
+++ Zope/branches/2.12/src/App/tests/testImageFile.py   2010-07-14 15:07:11 UTC 
(rev 114749)
@@ -0,0 +1,45 @@
+import unittest
+import os.path
+import App
+from Testing.ZopeTestCase.warnhook import WarningsHook
+
+
+class TestImageFile(unittest.TestCase):
+
+def setUp(self):
+# ugly: need to save the old App.config configuration value since
+# ImageFile might read it and trigger setting it to the default value 
+self.oldcfg = App.config._config
+self.warningshook = WarningsHook()
+self.warningshook.install()
+
+def tearDown(self):
+self.warningshook.uninstall()
+# ugly: need to restore configuration, or lack thereof
+App.config._config = self.oldcfg
+
+def test_warn_on_software_home_default(self):
+App.ImageFile.ImageFile('App/www/zopelogo.jpg')
+self.assertEquals(self.warningshook.warnings.pop()[0],
+  App.ImageFile.NON_PREFIX_WARNING)
+
+def test_no_warn_on_absolute_path(self):
+path = os.path.join(os.path.dirname(App.__file__),
+'www','zopelogo.jpg')
+App.ImageFile.ImageFile(path)
+self.failIf(self.warningshook.warnings)
+
+def test_no_warn_on_path_as_prefix(self):
+prefix = os.path.dirname(App.__file__)
+App.ImageFile.ImageFile('www/zopelogo.jpg', prefix)
+self.failIf(self.warningshook.warnings)
+
+def test_no_warn_on_namespace_as_prefix(self):
+prefix = App.__dict__ # same as calling globals() inside the App module
+App.ImageFile.ImageFile('www/zopelogo.jpg', prefix)
+self.failIf(self.warningshook.warnings)
+
+def test_suite():
+return unittest.TestSuite((
+unittest.makeSuite(TestImageFile),
+))

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


[Zope-Checkins] SVN: Zope/trunk/ Warn on App.ImageFile.ImageFile deprecated assumption of software_home. Forward ported 114749 from 2.12 branch

2010-07-14 Thread Leonardo Rochael Almeida
Log message for revision 114757:
  Warn on App.ImageFile.ImageFile deprecated assumption of software_home. 
Forward ported 114749 from 2.12 branch

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/App/ImageFile.py
  U   Zope/trunk/src/App/config.py
  A   Zope/trunk/src/App/tests/testImageFile.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===
--- Zope/trunk/doc/CHANGES.rst  2010-07-14 15:19:05 UTC (rev 114756)
+++ Zope/trunk/doc/CHANGES.rst  2010-07-14 15:46:50 UTC (rev 114757)
@@ -36,6 +36,11 @@
 Features Added
 ++
 
+- Warn when App.ImageFile.ImageFile receives a relative path with no prefix,
+  and then has to assume the path to be relative to software home. This
+  behaviour is deprecated as packages can be factored out to their own
+  distribution, making the software home relative path meaningless.
+
 - Updated packages:
 
   - ZODB3 = 3.10.0b2

Modified: Zope/trunk/src/App/ImageFile.py
===
--- Zope/trunk/src/App/ImageFile.py 2010-07-14 15:19:05 UTC (rev 114756)
+++ Zope/trunk/src/App/ImageFile.py 2010-07-14 15:46:50 UTC (rev 114757)
@@ -18,6 +18,7 @@
 import os.path
 import stat
 import time
+import warnings
 
 from AccessControl.class_init import InitializeClass
 from AccessControl.SecurityInfo import ClassSecurityInfo
@@ -34,6 +35,13 @@
 os.path.join(os.path.dirname(Zope2.__file__), os.path.pardir)
 )
 
+NON_PREFIX_WARNING = ('Assuming image location to be present in the Zope2 '
+  'distribution. This is deprecated and might lead to ' 
+  'broken code if the directory in question is moved ' 
+  'to another distribution. Please provide either an '
+  'absolute file system path or a prefix. Support for ' 
+  'relative filenames without a prefix might be '
+  'dropped in a future Zope2 release.')
 
 class ImageFile(Explicit):
 Image objects stored in external files.
@@ -43,9 +51,12 @@
 def __init__(self, path, _prefix=None):
 import Globals  # for data
 if _prefix is None:
-_prefix=getattr(getConfiguration(), 'softwarehome', PREFIX)
+_prefix=getattr(getConfiguration(), 'softwarehome', None) or PREFIX
+if not os.path.isabs(path):
+warnings.warn(NON_PREFIX_WARNING, UserWarning, 2 )
 elif type(_prefix) is not type(''):
 _prefix=package_home(_prefix)
+# _prefix is ignored if path is absolute
 path = os.path.join(_prefix, path)
 self.path=path
 if Globals.DevelopmentMode:

Modified: Zope/trunk/src/App/config.py
===
--- Zope/trunk/src/App/config.py2010-07-14 15:19:05 UTC (rev 114756)
+++ Zope/trunk/src/App/config.py2010-07-14 15:46:50 UTC (rev 114757)
@@ -36,7 +36,7 @@
 def setConfiguration(cfg):
 Set the global configuration object.
 
-Legacy sources of common configuraiton values are updated to
+Legacy sources of common configuration values are updated to
 reflect the new configuration; this may be removed in some future
 version.
 

Copied: Zope/trunk/src/App/tests/testImageFile.py (from rev 114749, 
Zope/branches/2.12/src/App/tests/testImageFile.py)
===
--- Zope/trunk/src/App/tests/testImageFile.py   (rev 0)
+++ Zope/trunk/src/App/tests/testImageFile.py   2010-07-14 15:46:50 UTC (rev 
114757)
@@ -0,0 +1,45 @@
+import unittest
+import os.path
+import App
+from Testing.ZopeTestCase.warnhook import WarningsHook
+
+
+class TestImageFile(unittest.TestCase):
+
+def setUp(self):
+# ugly: need to save the old App.config configuration value since
+# ImageFile might read it and trigger setting it to the default value 
+self.oldcfg = App.config._config
+self.warningshook = WarningsHook()
+self.warningshook.install()
+
+def tearDown(self):
+self.warningshook.uninstall()
+# ugly: need to restore configuration, or lack thereof
+App.config._config = self.oldcfg
+
+def test_warn_on_software_home_default(self):
+App.ImageFile.ImageFile('App/www/zopelogo.jpg')
+self.assertEquals(self.warningshook.warnings.pop()[0],
+  App.ImageFile.NON_PREFIX_WARNING)
+
+def test_no_warn_on_absolute_path(self):
+path = os.path.join(os.path.dirname(App.__file__),
+'www','zopelogo.jpg')
+App.ImageFile.ImageFile(path)
+self.failIf(self.warningshook.warnings)
+
+def test_no_warn_on_path_as_prefix(self):
+prefix = os.path.dirname(App.__file__)
+App.ImageFile.ImageFile('www/zopelogo.jpg', prefix)
+self.failIf(self.warningshook.warnings)
+
+def 

[Zope-Checkins] SVN: Zope/branches/rochael-TM_sortKey/ branch has been merged

2010-06-21 Thread Leonardo Rochael Almeida
Log message for revision 113726:
  branch has been merged

Changed:
  D   Zope/branches/rochael-TM_sortKey/

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


[Zope-Checkins] SVN: Zope/branches/rochael-TM_sortKey/doc/CHANGES.rst record setSortKey() changes

2010-06-18 Thread Leonardo Rochael Almeida
Log message for revision 113621:
  record setSortKey() changes

Changed:
  U   Zope/branches/rochael-TM_sortKey/doc/CHANGES.rst

-=-
Modified: Zope/branches/rochael-TM_sortKey/doc/CHANGES.rst
===
--- Zope/branches/rochael-TM_sortKey/doc/CHANGES.rst2010-06-18 18:27:43 UTC 
(rev 113620)
+++ Zope/branches/rochael-TM_sortKey/doc/CHANGES.rst2010-06-18 19:04:36 UTC 
(rev 113621)
@@ -38,6 +38,10 @@
   - Missing = 2.13.1
   - Persistence = 2.13.2
 
+- Added setSortKey() method to the Shared.DC.ZRDB.TM.TM class
+  to allow database connections to specify the commit order without
+  needing to override the sortKey() method.
+
 2.12.7 (2010-06-13)
 ---
 

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


[Zope-Checkins] SVN: Zope/branches/2.12/ merge branch rochael-TM_sortKey: add a setSortKey method to Shared.setSortKey() method to Shared.DC.ZRDB.TM.TM

2010-06-18 Thread Leonardo Rochael Almeida
Log message for revision 113622:
  merge branch rochael-TM_sortKey: add a setSortKey method to 
Shared.setSortKey() method to Shared.DC.ZRDB.TM.TM

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/Shared/DC/ZRDB/TM.py
  A   Zope/branches/2.12/src/Shared/DC/ZRDB/tests/testTM.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===
--- Zope/branches/2.12/doc/CHANGES.rst  2010-06-18 19:04:36 UTC (rev 113621)
+++ Zope/branches/2.12/doc/CHANGES.rst  2010-06-18 19:18:30 UTC (rev 113622)
@@ -38,6 +38,10 @@
   - Missing = 2.13.1
   - Persistence = 2.13.2
 
+- Added setSortKey() method to the Shared.DC.ZRDB.TM.TM class
+  to allow database connections to specify the commit order without
+  needing to override the sortKey() method.
+
 2.12.7 (2010-06-13)
 ---
 

Modified: Zope/branches/2.12/src/Shared/DC/ZRDB/TM.py
===
--- Zope/branches/2.12/src/Shared/DC/ZRDB/TM.py 2010-06-18 19:04:36 UTC (rev 
113621)
+++ Zope/branches/2.12/src/Shared/DC/ZRDB/TM.py 2010-06-18 19:18:30 UTC (rev 
113622)
@@ -26,7 +26,7 @@
 needed at the start of a transaction.
 
 A subclass that uses locking during transaction commit must
-defined a sortKey() method.
+define a sortKey() method.
 
 
 _registered=None
@@ -66,14 +66,19 @@
 
 tpc_abort = abort
 
+# Most DA's talking to RDBMS systems do not care about commit order, so
+# return the constant 1
+_sort_key = 1
+
 def sortKey(self, *ignored):
- The sortKey method is used for recent ZODB compatibility which
-needs to have a known commit order for lock acquisition.  Most
-DA's talking to RDBMS systems do not care about commit order, so
-return the constant 1
+ The sortKey method is used by ZODB to have a known commit order for
+lock acquisition.
 
-return 1
+return self._sort_key
 
+def setSortKey(self, sort_key):
+self._sort_key = sort_key
+
 class Surrogate:
 
 def __init__(self, db):

Copied: Zope/branches/2.12/src/Shared/DC/ZRDB/tests/testTM.py (from rev 113621, 
Zope/branches/rochael-TM_sortKey/src/Shared/DC/ZRDB/tests/testTM.py)
===
--- Zope/branches/2.12/src/Shared/DC/ZRDB/tests/testTM.py   
(rev 0)
+++ Zope/branches/2.12/src/Shared/DC/ZRDB/tests/testTM.py   2010-06-18 
19:18:30 UTC (rev 113622)
@@ -0,0 +1,29 @@
+##
+#
+# Copyright (c) 2009 Zope Foundation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED AS IS AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##
+
+from unittest import TestCase, TestSuite, makeSuite
+from Shared.DC.ZRDB.TM import TM
+
+class TestTM(TestCase):
+
+def test_sortKey(self):
+tm = TM()
+# the default Transaction Manager should have .sortKey() of 1 for
+# backward compatibility
+self.assertEquals(tm.sortKey(), 1)
+# but the sortKey() should be adjustable
+tm.setSortKey(())
+self.assertEquals(tm.sortKey(), ())
+
+def test_suite():
+return TestSuite((makeSuite(TestTM),))

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


[Zope-Checkins] SVN: Zope/trunk/ merge branch rochael-TM_sortKey: add a setSortKey method to Shared.setSortKey() method to Shared.DC.ZRDB.TM.TM

2010-06-18 Thread Leonardo Rochael Almeida
Log message for revision 113623:
  merge branch rochael-TM_sortKey: add a setSortKey method to 
Shared.setSortKey() method to Shared.DC.ZRDB.TM.TM

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/Shared/DC/ZRDB/TM.py
  A   Zope/trunk/src/Shared/DC/ZRDB/tests/testTM.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===
--- Zope/trunk/doc/CHANGES.rst  2010-06-18 19:18:30 UTC (rev 113622)
+++ Zope/trunk/doc/CHANGES.rst  2010-06-18 19:33:34 UTC (rev 113623)
@@ -145,6 +145,10 @@
 - ZCTextIndex query parser treats fullwidth space characters defined
   in Unicode as valid white space.
 
+- Added ``setSortKey()`` method to the ``Shared.DC.ZRDB.TM.TM`` class
+  to allow database connections to specify the commit order without
+  needing to override the ``sortKey()`` method.
+
 - Updated packages:
 
   - Jinja2 = 2.5.0

Modified: Zope/trunk/src/Shared/DC/ZRDB/TM.py
===
--- Zope/trunk/src/Shared/DC/ZRDB/TM.py 2010-06-18 19:18:30 UTC (rev 113622)
+++ Zope/trunk/src/Shared/DC/ZRDB/TM.py 2010-06-18 19:33:34 UTC (rev 113623)
@@ -26,7 +26,7 @@
 needed at the start of a transaction.
 
 A subclass that uses locking during transaction commit must
-defined a sortKey() method.
+define a sortKey() method.
 
 
 _registered=None
@@ -66,14 +66,19 @@
 
 tpc_abort = abort
 
+# Most DA's talking to RDBMS systems do not care about commit order, so
+# return the constant 1
+_sort_key = 1
+
 def sortKey(self, *ignored):
- The sortKey method is used for recent ZODB compatibility which
-needs to have a known commit order for lock acquisition.  Most
-DA's talking to RDBMS systems do not care about commit order, so
-return the constant 1
+ The sortKey method is used by the transaction subsystem to have a
+known commit order for lock acquisition.
 
-return 1
+return self._sort_key
 
+def setSortKey(self, sort_key):
+self._sort_key = sort_key
+
 class Surrogate:
 
 def __init__(self, db):

Copied: Zope/trunk/src/Shared/DC/ZRDB/tests/testTM.py (from rev 113621, 
Zope/branches/rochael-TM_sortKey/src/Shared/DC/ZRDB/tests/testTM.py)
===
--- Zope/trunk/src/Shared/DC/ZRDB/tests/testTM.py   
(rev 0)
+++ Zope/trunk/src/Shared/DC/ZRDB/tests/testTM.py   2010-06-18 19:33:34 UTC 
(rev 113623)
@@ -0,0 +1,30 @@
+##
+#
+# Copyright (c) 2010 Zope Foundation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED AS IS AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##
+
+from unittest import TestCase, TestSuite, makeSuite
+from Shared.DC.ZRDB.TM import TM
+
+class TestTM(TestCase):
+
+def test_sortKey(self):
+tm = TM()
+# the default Transaction Manager should have .sortKey() of 1 for
+# backward compatibility
+self.assertEquals(tm.sortKey(), 1)
+# but the sortKey() should be adjustable
+tm.setSortKey(())
+self.assertEquals(tm.sortKey(), ())
+
+def test_suite():
+return TestSuite((makeSuite(TestTM),))
+

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


[Zope-Checkins] SVN: Zope/branches/2.12/ ReST changes, and it's a new year already

2010-06-18 Thread Leonardo Rochael Almeida
Log message for revision 113624:
  ReST changes, and it's a new year already

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/Shared/DC/ZRDB/tests/testTM.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===
--- Zope/branches/2.12/doc/CHANGES.rst  2010-06-18 19:33:34 UTC (rev 113623)
+++ Zope/branches/2.12/doc/CHANGES.rst  2010-06-18 19:38:08 UTC (rev 113624)
@@ -38,9 +38,9 @@
   - Missing = 2.13.1
   - Persistence = 2.13.2
 
-- Added setSortKey() method to the Shared.DC.ZRDB.TM.TM class
+- Added ``setSortKey()`` method to the ``Shared.DC.ZRDB.TM.TM`` class
   to allow database connections to specify the commit order without
-  needing to override the sortKey() method.
+  needing to override the ``sortKey()`` method.
 
 2.12.7 (2010-06-13)
 ---

Modified: Zope/branches/2.12/src/Shared/DC/ZRDB/tests/testTM.py
===
--- Zope/branches/2.12/src/Shared/DC/ZRDB/tests/testTM.py   2010-06-18 
19:33:34 UTC (rev 113623)
+++ Zope/branches/2.12/src/Shared/DC/ZRDB/tests/testTM.py   2010-06-18 
19:38:08 UTC (rev 113624)
@@ -1,6 +1,6 @@
 ##
 #
-# Copyright (c) 2009 Zope Foundation and Contributors.
+# Copyright (c) 2010 Zope Foundation and Contributors.
 #
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.

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


[Zope-Checkins] SVN: Zope/branches/rochael-TM_sortKey/ branch for adjustable sortKey() for Shared.DC.ZRDB.TM

2010-06-17 Thread Leonardo Rochael Almeida
Log message for revision 113596:
  branch for adjustable sortKey() for Shared.DC.ZRDB.TM
  

Changed:
  A   Zope/branches/rochael-TM_sortKey/

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


[Zope-Checkins] SVN: Zope/branches/rochael-TM_sortKey/src/Shared/DC/ZRDB/ make the result of Shared.DC.ZRDB.TM.TM.sortKey() adjustable

2010-06-17 Thread Leonardo Rochael Almeida
Log message for revision 113597:
  make the result of Shared.DC.ZRDB.TM.TM.sortKey() adjustable

Changed:
  U   Zope/branches/rochael-TM_sortKey/src/Shared/DC/ZRDB/TM.py
  A   Zope/branches/rochael-TM_sortKey/src/Shared/DC/ZRDB/tests/testTM.py

-=-
Modified: Zope/branches/rochael-TM_sortKey/src/Shared/DC/ZRDB/TM.py
===
--- Zope/branches/rochael-TM_sortKey/src/Shared/DC/ZRDB/TM.py   2010-06-18 
00:08:58 UTC (rev 113596)
+++ Zope/branches/rochael-TM_sortKey/src/Shared/DC/ZRDB/TM.py   2010-06-18 
00:17:09 UTC (rev 113597)
@@ -26,7 +26,7 @@
 needed at the start of a transaction.
 
 A subclass that uses locking during transaction commit must
-defined a sortKey() method.
+define a sortKey() method.
 
 
 _registered=None
@@ -66,14 +66,19 @@
 
 tpc_abort = abort
 
+# Most DA's talking to RDBMS systems do not care about commit order, so
+# return the constant 1
+_sort_key = 1
+
 def sortKey(self, *ignored):
- The sortKey method is used for recent ZODB compatibility which
-needs to have a known commit order for lock acquisition.  Most
-DA's talking to RDBMS systems do not care about commit order, so
-return the constant 1
+ The sortKey method is used by ZODB to have a known commit order for
+lock acquisition.
 
-return 1
+return self._sort_key
 
+def setSortKey(self, sort_key):
+self._sort_key = sort_key
+
 class Surrogate:
 
 def __init__(self, db):

Added: Zope/branches/rochael-TM_sortKey/src/Shared/DC/ZRDB/tests/testTM.py
===
--- Zope/branches/rochael-TM_sortKey/src/Shared/DC/ZRDB/tests/testTM.py 
(rev 0)
+++ Zope/branches/rochael-TM_sortKey/src/Shared/DC/ZRDB/tests/testTM.py 
2010-06-18 00:17:09 UTC (rev 113597)
@@ -0,0 +1,29 @@
+##
+#
+# Copyright (c) 2009 Zope Foundation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED AS IS AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##
+
+from unittest import TestCase, TestSuite, makeSuite
+from Shared.DC.ZRDB.TM import TM
+
+class TestTM(TestCase):
+
+def test_sortKey(self):
+tm = TM()
+# the default Transaction Manager should have .sortKey() of 1 for
+# backward compatibility
+self.assertEquals(tm.sortKey(), 1)
+# but the sortKey() should be adjustable
+tm.setSortKey(())
+self.assertEquals(tm.sortKey(), ())
+
+def test_suite():
+return TestSuite((makeSuite(TestTM),))

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


[Zope-Checkins] SVN: Zope/branches/2.12/src/Products/StandardCacheManagers/ fix lp #534653, reset *CacheManager module level cache id on clone

2010-03-12 Thread Leonardo Rochael Almeida
Log message for revision 109929:
  fix lp #534653, reset *CacheManager module level cache id on clone

Changed:
  U   
Zope/branches/2.12/src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
  U   Zope/branches/2.12/src/Products/StandardCacheManagers/RAMCacheManager.py
  A   Zope/branches/2.12/src/Products/StandardCacheManagers/configure.zcml
  A   Zope/branches/2.12/src/Products/StandardCacheManagers/subscribers.py
  A   
Zope/branches/2.12/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py

-=-
Modified: 
Zope/branches/2.12/src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
===
--- 
Zope/branches/2.12/src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
2010-03-12 15:37:56 UTC (rev 109928)
+++ 
Zope/branches/2.12/src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
2010-03-12 16:07:59 UTC (rev 109929)
@@ -166,12 +166,16 @@
 self._settings = {'anonymous_only':1,
   'interval':3600,
   'notify_urls':()}
-self.__cacheid = '%s_%f' % (id(self), time.time())
+self._resetCacheId()
 
 def getId(self):
 ' '
 return self.id
 
+security.declarePrivate('_resetCacheId')
+def _resetCacheId(self):
+self.__cacheid = '%s_%f' % (id(self), time.time())
+
 security.declarePrivate('ZCacheManager_getCache')
 def ZCacheManager_getCache(self):
 cacheid = self.__cacheid

Modified: 
Zope/branches/2.12/src/Products/StandardCacheManagers/RAMCacheManager.py
===
--- Zope/branches/2.12/src/Products/StandardCacheManagers/RAMCacheManager.py
2010-03-12 15:37:56 UTC (rev 109928)
+++ Zope/branches/2.12/src/Products/StandardCacheManagers/RAMCacheManager.py
2010-03-12 16:07:59 UTC (rev 109929)
@@ -374,12 +374,16 @@
 'request_vars': ('AUTHENTICATED_USER',),
 'max_age': 3600,
 }
-self.__cacheid = '%s_%f' % (id(self), time.time())
+self._resetCacheId()
 
 def getId(self):
 ' '
 return self.id
 
+security.declarePrivate('_resetCacheId')
+def _resetCacheId(self):
+self.__cacheid = '%s_%f' % (id(self), time.time())
+
 ZCacheManager_getCache__roles__ = ()
 def ZCacheManager_getCache(self):
 cacheid = self.__cacheid

Added: Zope/branches/2.12/src/Products/StandardCacheManagers/configure.zcml
===
--- Zope/branches/2.12/src/Products/StandardCacheManagers/configure.zcml
(rev 0)
+++ Zope/branches/2.12/src/Products/StandardCacheManagers/configure.zcml
2010-03-12 16:07:59 UTC (rev 109929)
@@ -0,0 +1,13 @@
+configure xmlns=http://namespaces.zope.org/zope;
+
+  subscriber
+for=Products.StandardCacheManagers.RAMCacheManager.RAMCacheManager
+ OFS.interfaces.IObjectClonedEvent
+handler=Products.StandardCacheManagers.subscribers.cloned /
+
+  subscriber
+
for=Products.StandardCacheManagers.AcceleratedHTTPCacheManager.AcceleratedHTTPCacheManager
+ OFS.interfaces.IObjectClonedEvent
+handler=Products.StandardCacheManagers.subscribers.cloned /
+
+/configure

Added: Zope/branches/2.12/src/Products/StandardCacheManagers/subscribers.py
===
--- Zope/branches/2.12/src/Products/StandardCacheManagers/subscribers.py
(rev 0)
+++ Zope/branches/2.12/src/Products/StandardCacheManagers/subscribers.py
2010-03-12 16:07:59 UTC (rev 109929)
@@ -0,0 +1,24 @@
+##
+#
+# Copyright (c) 2010 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED AS IS AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##
+ subscribers to events affecting StandardCacheManagers
+
+
+
+def cloned(obj, event):
+
+Reset the Id of the module level cache so the clone gets a different cache
+than its source object
+ 
+obj._resetCacheId()
+

Added: 
Zope/branches/2.12/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py
===
--- 
Zope/branches/2.12/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py
(rev 0)
+++ 

[Zope-Checkins] SVN: Zope/trunk/ forward port r109929: fix for lp #534653

2010-03-12 Thread Leonardo Rochael Almeida
Log message for revision 109931:
  forward port r109929: fix for lp #534653

Changed:
  _U  Zope/trunk/
  U   
Zope/trunk/src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
  U   Zope/trunk/src/Products/StandardCacheManagers/RAMCacheManager.py
  A   Zope/trunk/src/Products/StandardCacheManagers/configure.zcml
  A   Zope/trunk/src/Products/StandardCacheManagers/subscribers.py
  A   
Zope/trunk/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py

-=-

Property changes on: Zope/trunk
___
Added: svn:mergeinfo
   + /Zope/branches/2.12:109929

Modified: 
Zope/trunk/src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
===
--- 
Zope/trunk/src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
2010-03-12 16:22:28 UTC (rev 109930)
+++ 
Zope/trunk/src/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
2010-03-12 16:28:15 UTC (rev 109931)
@@ -166,12 +166,16 @@
 self._settings = {'anonymous_only':1,
   'interval':3600,
   'notify_urls':()}
-self.__cacheid = '%s_%f' % (id(self), time.time())
+self._resetCacheId()
 
 def getId(self):
 ' '
 return self.id
 
+security.declarePrivate('_resetCacheId')
+def _resetCacheId(self):
+self.__cacheid = '%s_%f' % (id(self), time.time())
+
 security.declarePrivate('ZCacheManager_getCache')
 def ZCacheManager_getCache(self):
 cacheid = self.__cacheid

Modified: Zope/trunk/src/Products/StandardCacheManagers/RAMCacheManager.py
===
--- Zope/trunk/src/Products/StandardCacheManagers/RAMCacheManager.py
2010-03-12 16:22:28 UTC (rev 109930)
+++ Zope/trunk/src/Products/StandardCacheManagers/RAMCacheManager.py
2010-03-12 16:28:15 UTC (rev 109931)
@@ -374,12 +374,16 @@
 'request_vars': ('AUTHENTICATED_USER',),
 'max_age': 3600,
 }
-self.__cacheid = '%s_%f' % (id(self), time.time())
+self._resetCacheId()
 
 def getId(self):
 ' '
 return self.id
 
+security.declarePrivate('_resetCacheId')
+def _resetCacheId(self):
+self.__cacheid = '%s_%f' % (id(self), time.time())
+
 ZCacheManager_getCache__roles__ = ()
 def ZCacheManager_getCache(self):
 cacheid = self.__cacheid

Copied: Zope/trunk/src/Products/StandardCacheManagers/configure.zcml (from rev 
109929, Zope/branches/2.12/src/Products/StandardCacheManagers/configure.zcml)
===
--- Zope/trunk/src/Products/StandardCacheManagers/configure.zcml
(rev 0)
+++ Zope/trunk/src/Products/StandardCacheManagers/configure.zcml
2010-03-12 16:28:15 UTC (rev 109931)
@@ -0,0 +1,13 @@
+configure xmlns=http://namespaces.zope.org/zope;
+
+  subscriber
+for=Products.StandardCacheManagers.RAMCacheManager.RAMCacheManager
+ OFS.interfaces.IObjectClonedEvent
+handler=Products.StandardCacheManagers.subscribers.cloned /
+
+  subscriber
+
for=Products.StandardCacheManagers.AcceleratedHTTPCacheManager.AcceleratedHTTPCacheManager
+ OFS.interfaces.IObjectClonedEvent
+handler=Products.StandardCacheManagers.subscribers.cloned /
+
+/configure

Copied: Zope/trunk/src/Products/StandardCacheManagers/subscribers.py (from rev 
109929, Zope/branches/2.12/src/Products/StandardCacheManagers/subscribers.py)
===
--- Zope/trunk/src/Products/StandardCacheManagers/subscribers.py
(rev 0)
+++ Zope/trunk/src/Products/StandardCacheManagers/subscribers.py
2010-03-12 16:28:15 UTC (rev 109931)
@@ -0,0 +1,24 @@
+##
+#
+# Copyright (c) 2010 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED AS IS AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##
+ subscribers to events affecting StandardCacheManagers
+
+
+
+def cloned(obj, event):
+
+Reset the Id of the module level cache so the clone gets a different cache
+than its source object
+ 
+obj._resetCacheId()
+

Copied: 
Zope/trunk/src/Products/StandardCacheManagers/tests/test_CacheManagerLocation.py
 (from rev 109929, 

[Zope-Checkins] SVN: Zope/branches/2.12/ LP #246983: Unicode conflict resolution on variables inside 'string:' expressions

2010-01-05 Thread Leonardo Rochael Almeida
Log message for revision 107725:
  LP #246983: Unicode conflict resolution on variables inside 'string:' 
expressions

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   
Zope/branches/2.12/src/Products/Five/browser/tests/test_pagetemplatefile.py
  U   Zope/branches/2.12/src/Products/PageTemplates/Expressions.py
  U   Zope/branches/2.12/src/Products/PageTemplates/tests/testExpressions.py
  U   
Zope/branches/2.12/src/Products/PageTemplates/tests/testZopePageTemplate.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===
--- Zope/branches/2.12/doc/CHANGES.rst  2010-01-05 22:37:00 UTC (rev 107724)
+++ Zope/branches/2.12/doc/CHANGES.rst  2010-01-06 01:31:21 UTC (rev 107725)
@@ -11,6 +11,9 @@
 Bugs Fixed
 ++
 
+- LP #246983: Enabled unicode conflict resolution on variables inside string:
+  expressions in TALES.
+
 - Fixed possible TypeError while sending multipart emails.
 
 - Also look for ZEXP imports within the clienthome directory. This

Modified: 
Zope/branches/2.12/src/Products/Five/browser/tests/test_pagetemplatefile.py
===
--- Zope/branches/2.12/src/Products/Five/browser/tests/test_pagetemplatefile.py 
2010-01-05 22:37:00 UTC (rev 107724)
+++ Zope/branches/2.12/src/Products/Five/browser/tests/test_pagetemplatefile.py 
2010-01-06 01:31:21 UTC (rev 107725)
@@ -37,13 +37,13 @@
 from zope.tales.expressions import DeferExpr
 from zope.tales.expressions import NotExpr
 from zope.tales.expressions import PathExpr
-from zope.tales.expressions import StringExpr
 from zope.tales.expressions import Undefs
 from zope.tales.pythonexpr import PythonExpr
 from zope.contentprovider.tales import TALESProviderExpression
 from Products.PageTemplates.DeferExpr import LazyExpr
 from Products.PageTemplates.Expressions import TrustedZopePathExpr
 from Products.PageTemplates.Expressions import SecureModuleImporter
+from Products.PageTemplates.Expressions import UnicodeAwareStringExpr
 
 vptf = self._makeOne('seagull.pt')
 engine = vptf.pt_getEngine()
@@ -51,7 +51,7 @@
 self.assertEqual(engine.types['path'], TrustedZopePathExpr)
 self.assertEqual(engine.types['exists'], TrustedZopePathExpr)
 self.assertEqual(engine.types['nocall'], TrustedZopePathExpr)
-self.assertEqual(engine.types['string'], StringExpr)
+self.assertEqual(engine.types['string'], UnicodeAwareStringExpr)
 self.assertEqual(engine.types['python'], PythonExpr)
 self.assertEqual(engine.types['not'], NotExpr)
 self.assertEqual(engine.types['defer'], DeferExpr)

Modified: Zope/branches/2.12/src/Products/PageTemplates/Expressions.py
===
--- Zope/branches/2.12/src/Products/PageTemplates/Expressions.py
2010-01-05 22:37:00 UTC (rev 107724)
+++ Zope/branches/2.12/src/Products/PageTemplates/Expressions.py
2010-01-06 01:31:21 UTC (rev 107725)
@@ -372,12 +372,26 @@
 return False
 return ob1 == ob2
 
+class UnicodeAwareStringExpr(StringExpr):
+
+def __call__(self, econtext):
+vvals = []
+if isinstance(self._expr, unicode):
+# coerce values through the Unicode Conflict Resolver
+evaluate = econtext.evaluateText
+else:
+evaluate = econtext.evaluate
+for var in self._vars:
+v = evaluate(var)
+vvals.append(v)
+return self._expr % tuple(vvals)
+
 def createZopeEngine(zpe=ZopePathExpr):
 e = ZopeEngine()
 e.iteratorFactory = PathIterator
 for pt in zpe._default_type_names:
 e.registerType(pt, zpe)
-e.registerType('string', StringExpr)
+e.registerType('string', UnicodeAwareStringExpr)
 e.registerType('python', ZRPythonExpr.PythonExpr)
 e.registerType('not', NotExpr)
 e.registerType('defer', DeferExpr)

Modified: Zope/branches/2.12/src/Products/PageTemplates/tests/testExpressions.py
===
--- Zope/branches/2.12/src/Products/PageTemplates/tests/testExpressions.py  
2010-01-05 22:37:00 UTC (rev 107724)
+++ Zope/branches/2.12/src/Products/PageTemplates/tests/testExpressions.py  
2010-01-06 01:31:21 UTC (rev 107725)
@@ -25,12 +25,20 @@
 __allow_access_to_unprotected_subobjects__ = 1
 def __call__(self):
 return 'dummy'
+
+management_page_charset = 'iso-8859-15'
 
 class DummyDocumentTemplate:
 __allow_access_to_unprotected_subobjects__ = 1
 isDocTemp = True
 def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw):
 return 'dummy'
+
+def absolute_url(self, relative=0):
+url = 'dummy'
+if 

[Zope-Checkins] SVN: Zope/trunk/ merge 107725 from 2.12: fix for LP #246983

2010-01-05 Thread Leonardo Rochael Almeida
Log message for revision 107726:
  merge 107725 from 2.12: fix for LP #246983

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/Products/Five/browser/tests/test_pagetemplatefile.py
  U   Zope/trunk/src/Products/PageTemplates/Expressions.py
  U   Zope/trunk/src/Products/PageTemplates/tests/testExpressions.py
  U   Zope/trunk/src/Products/PageTemplates/tests/testZopePageTemplate.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===
--- Zope/trunk/doc/CHANGES.rst  2010-01-06 01:31:21 UTC (rev 107725)
+++ Zope/trunk/doc/CHANGES.rst  2010-01-06 01:50:37 UTC (rev 107726)
@@ -125,6 +125,9 @@
 Bugs Fixed
 ++
 
+- LP #246983: Enabled unicode conflict resolution on variables inside string:
+  expressions in TALES.
+
 - Also look for ZEXP imports within the clienthome directory. This
   provides a place to put imports that won't be clobbered by buildout
   in a buildout-based Zope instance.

Modified: Zope/trunk/src/Products/Five/browser/tests/test_pagetemplatefile.py
===
--- Zope/trunk/src/Products/Five/browser/tests/test_pagetemplatefile.py 
2010-01-06 01:31:21 UTC (rev 107725)
+++ Zope/trunk/src/Products/Five/browser/tests/test_pagetemplatefile.py 
2010-01-06 01:50:37 UTC (rev 107726)
@@ -37,13 +37,13 @@
 from zope.tales.expressions import DeferExpr
 from zope.tales.expressions import NotExpr
 from zope.tales.expressions import PathExpr
-from zope.tales.expressions import StringExpr
 from zope.tales.expressions import Undefs
 from zope.tales.pythonexpr import PythonExpr
 from zope.contentprovider.tales import TALESProviderExpression
 from Products.PageTemplates.DeferExpr import LazyExpr
 from Products.PageTemplates.Expressions import TrustedZopePathExpr
 from Products.PageTemplates.Expressions import SecureModuleImporter
+from Products.PageTemplates.Expressions import UnicodeAwareStringExpr
 
 vptf = self._makeOne('seagull.pt')
 engine = vptf.pt_getEngine()
@@ -51,7 +51,7 @@
 self.assertEqual(engine.types['path'], TrustedZopePathExpr)
 self.assertEqual(engine.types['exists'], TrustedZopePathExpr)
 self.assertEqual(engine.types['nocall'], TrustedZopePathExpr)
-self.assertEqual(engine.types['string'], StringExpr)
+self.assertEqual(engine.types['string'], UnicodeAwareStringExpr)
 self.assertEqual(engine.types['python'], PythonExpr)
 self.assertEqual(engine.types['not'], NotExpr)
 self.assertEqual(engine.types['defer'], DeferExpr)

Modified: Zope/trunk/src/Products/PageTemplates/Expressions.py
===
--- Zope/trunk/src/Products/PageTemplates/Expressions.py2010-01-06 
01:31:21 UTC (rev 107725)
+++ Zope/trunk/src/Products/PageTemplates/Expressions.py2010-01-06 
01:50:37 UTC (rev 107726)
@@ -372,12 +372,26 @@
 return False
 return ob1 == ob2
 
+class UnicodeAwareStringExpr(StringExpr):
+
+def __call__(self, econtext):
+vvals = []
+if isinstance(self._expr, unicode):
+# coerce values through the Unicode Conflict Resolver
+evaluate = econtext.evaluateText
+else:
+evaluate = econtext.evaluate
+for var in self._vars:
+v = evaluate(var)
+vvals.append(v)
+return self._expr % tuple(vvals)
+
 def createZopeEngine(zpe=ZopePathExpr):
 e = ZopeEngine()
 e.iteratorFactory = PathIterator
 for pt in zpe._default_type_names:
 e.registerType(pt, zpe)
-e.registerType('string', StringExpr)
+e.registerType('string', UnicodeAwareStringExpr)
 e.registerType('python', ZRPythonExpr.PythonExpr)
 e.registerType('not', NotExpr)
 e.registerType('defer', DeferExpr)

Modified: Zope/trunk/src/Products/PageTemplates/tests/testExpressions.py
===
--- Zope/trunk/src/Products/PageTemplates/tests/testExpressions.py  
2010-01-06 01:31:21 UTC (rev 107725)
+++ Zope/trunk/src/Products/PageTemplates/tests/testExpressions.py  
2010-01-06 01:50:37 UTC (rev 107726)
@@ -25,12 +25,20 @@
 __allow_access_to_unprotected_subobjects__ = 1
 def __call__(self):
 return 'dummy'
+
+management_page_charset = 'iso-8859-15'
 
 class DummyDocumentTemplate:
 __allow_access_to_unprotected_subobjects__ = 1
 isDocTemp = True
 def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw):
 return 'dummy'
+
+def absolute_url(self, relative=0):
+url = 'dummy'
+if not relative:
+url = http://server/; + url
+return url
 
 _DEFAULT_BINDINGS = dict(
   

[Zope-Checkins] SVN: Zope/trunk/src/Shared/DC/ZRDB/Connection.py Forward port 105096 to trunk. Missed Globals removal.

2009-10-15 Thread Leonardo Rochael Almeida
Log message for revision 105097:
  Forward port 105096 to trunk. Missed Globals removal.

Changed:
  U   Zope/trunk/src/Shared/DC/ZRDB/Connection.py

-=-
Modified: Zope/trunk/src/Shared/DC/ZRDB/Connection.py
===
--- Zope/trunk/src/Shared/DC/ZRDB/Connection.py 2009-10-15 20:00:37 UTC (rev 
105096)
+++ Zope/trunk/src/Shared/DC/ZRDB/Connection.py 2009-10-15 20:03:56 UTC (rev 
105097)
@@ -70,7 +70,7 @@
 self.edit(title, connection_string, check)
 
 def __setstate__(self, state):
-Globals.Persistent.__setstate__(self, state)
+Persistent.__setstate__(self, state)
 if self.connection_string:
 try: self.connect(self.connection_string)
 except:

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


[Zope-Checkins] SVN: Zope/branches/2.12/src/Shared/DC/ZRDB/Connection.py Tres, you missed a spot

2009-10-15 Thread Leonardo Rochael Almeida
Log message for revision 105096:
  Tres, you missed a spot

Changed:
  U   Zope/branches/2.12/src/Shared/DC/ZRDB/Connection.py

-=-
Modified: Zope/branches/2.12/src/Shared/DC/ZRDB/Connection.py
===
--- Zope/branches/2.12/src/Shared/DC/ZRDB/Connection.py 2009-10-15 19:47:09 UTC 
(rev 105095)
+++ Zope/branches/2.12/src/Shared/DC/ZRDB/Connection.py 2009-10-15 20:00:37 UTC 
(rev 105096)
@@ -70,7 +70,7 @@
 self.edit(title, connection_string, check)
 
 def __setstate__(self, state):
-Globals.Persistent.__setstate__(self, state)
+Persistent.__setstate__(self, state)
 if self.connection_string:
 try: self.connect(self.connection_string)
 except:

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


[Zope-Checkins] SVN: Zope/branches/2.12/src/HelpSys/APIHelpTopic.py Fix HelpSys to work with zope.interface.Interface as it did before the deprecated methods of scarecrow Interface.Interface were remo

2009-10-14 Thread Leonardo Rochael Almeida
Log message for revision 105060:
  Fix HelpSys to work with zope.interface.Interface as it did before the 
deprecated methods of scarecrow Interface.Interface were removed.

Changed:
  U   Zope/branches/2.12/src/HelpSys/APIHelpTopic.py

-=-
Modified: Zope/branches/2.12/src/HelpSys/APIHelpTopic.py
===
--- Zope/branches/2.12/src/HelpSys/APIHelpTopic.py  2009-10-14 08:35:10 UTC 
(rev 105059)
+++ Zope/branches/2.12/src/HelpSys/APIHelpTopic.py  2009-10-14 08:54:25 UTC 
(rev 105060)
@@ -48,8 +48,8 @@
 if type(v)==types.ClassType:
 # A class.
 self.apis.append(APIDoc(v, 0))
-elif (hasattr(v, 'isImplementedByInstancesOf')):
-# A scarecrow interface.
+elif (hasattr(v, 'implementedBy')):
+# A zope.interface.Interface.
 self.apis.append(APIDoc(v, 1))
 elif type(v)==types.FunctionType:
 # A function

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


[Zope-Checkins] SVN: Zope/trunk/src/HelpSys/APIHelpTopic.py Merge 105060 from branch 2.12: Fix HelpSys to work with zope.interface.Interface as it did before the deprecated methods of scarecrow Interf

2009-10-14 Thread Leonardo Rochael Almeida
Log message for revision 105062:
  Merge 105060 from branch 2.12: Fix HelpSys to work with 
zope.interface.Interface as it did before the deprecated methods of scarecrow 
Interface.Interface were removed.

Changed:
  U   Zope/trunk/src/HelpSys/APIHelpTopic.py

-=-
Modified: Zope/trunk/src/HelpSys/APIHelpTopic.py
===
--- Zope/trunk/src/HelpSys/APIHelpTopic.py  2009-10-14 08:54:58 UTC (rev 
105061)
+++ Zope/trunk/src/HelpSys/APIHelpTopic.py  2009-10-14 08:57:25 UTC (rev 
105062)
@@ -48,8 +48,8 @@
 if type(v)==types.ClassType:
 # A class.
 self.apis.append(APIDoc(v, 0))
-elif (hasattr(v, 'isImplementedByInstancesOf')):
-# A scarecrow interface.
+elif (hasattr(v, 'implementedBy')):
+# A zope.interface.Interface.
 self.apis.append(APIDoc(v, 1))
 elif type(v)==types.FunctionType:
 # A function

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


[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/ revert ZCatalog.getobject() semantics not to mask traversal errors and not to fallback to .resolve_url() when the trav

2006-11-17 Thread Leonardo Rochael Almeida
Log message for revision 71167:
  revert ZCatalog.getobject() semantics not to mask traversal errors and not to 
fallback to .resolve_url() when the traversal result is None
  

Changed:
  U   Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/ZCatalog.py
  U   
Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/tests/testCatalog.py

-=-
Modified: Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/ZCatalog.py
===
--- Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/ZCatalog.py  
2006-11-17 18:32:00 UTC (rev 71166)
+++ Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/ZCatalog.py  
2006-11-17 19:51:12 UTC (rev 71167)
@@ -615,12 +615,7 @@
 def getobject(self, rid, REQUEST=None):
 Return a cataloged object given a 'data_record_id_'
 
-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)
-return obj
+return self.aq_parent.unrestrictedTraverse(self.getpath(rid))
 
 def getMetadataForUID(self, uid):
 return the correct metadata given the uid, usually the path

Modified: 
Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/tests/testCatalog.py
===
--- 
Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/tests/testCatalog.py 
2006-11-17 18:32:00 UTC (rev 71166)
+++ 
Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/tests/testCatalog.py 
2006-11-17 19:51:12 UTC (rev 71167)
@@ -177,15 +177,23 @@
 def __nonzero__(self):
 self.fail(__nonzero__() was called)
 
+class FakeTraversalError(KeyError):
+fake traversal exception for testing
+
 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)
+marker = object()
 
+def unrestrictedTraverse(self, path, default=marker):
+result = self.d.get(path, default)
+if result is self.marker:
+raise FakeTraversalError(path)
+return result
+
 class TestZCatalog(unittest.TestCase):
 
 def setUp(self):
@@ -283,7 +291,7 @@
 self._catalog.manage_catalogObject(None, myresponse(), 'URL1', 
urls=('11', '12'))
 
 def testBooleanEvalOn_refreshCatalog_getobject(self):
-# wrap catalog under the fake parent
+# wrap catalog under the fake parent providing unrestrictedTraverse()
 catalog = self._catalog.__of__(fakeparent(self.d))
 # replace entries to test refreshCatalog
 self.d['0'] = dummyLenFail(0, self.fail)
@@ -292,10 +300,27 @@
 catalog.refreshCatalog()
 
 for uid in ('0', '1'):
-rid = self._catalog.getrid(uid)
+rid = catalog.getrid(uid)
 # neither should these
 catalog.getobject(rid)
 
+def 
test_getobject_doesntMaskTraversalErrorsAndDoesntDelegateTo_resolve_url(self):
+# wrap catalog under the fake parent providing unrestrictedTraverse()
+catalog = self._catalog.__of__(fakeparent(self.d))
+# make resolve_url fail if ZCatalog falls back on it
+def resolve_url(path, REQUEST):
+self.fail(.resolve_url() should not be called by .getobject())
+catalog.resolve_url = resolve_url
+
+# traversal should work at first
+rid0 = catalog.getrid('0')
+# lets set it up so the traversal fails
+del self.d['0']
+self.assertRaises(FakeTraversalError, catalog.getobject, rid0, 
REQUEST=object())
+# and if there is a None at the traversal point, that's where it 
should return
+self.d['0'] = None
+self.assertEquals(catalog.getobject(rid0), None)
+
 class dummy(ExtensionClass.Base):
 att1 = 'att1'
 att2 = 'att2'

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


[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Products/ZCatalog/ revert ZCatalog.getobject() semantics not to mask traversal errors and not to fallback to .resolve_url() when the traversal result

2006-11-17 Thread Leonardo Rochael Almeida
Log message for revision 71168:
  revert ZCatalog.getobject() semantics not to mask traversal errors and not to 
fallback to .resolve_url() when the traversal result is None
  

Changed:
  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/lib/python/Products/ZCatalog/ZCatalog.py
===
--- Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py  2006-11-17 
19:51:12 UTC (rev 71167)
+++ Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py  2006-11-17 
20:01:22 UTC (rev 71168)
@@ -615,12 +615,7 @@
 def getobject(self, rid, REQUEST=None):
 Return a cataloged object given a 'data_record_id_'
 
-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)
-return obj
+return self.aq_parent.unrestrictedTraverse(self.getpath(rid))
 
 def getMetadataForUID(self, uid):
 return the correct metadata given the uid, usually the path

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-17 19:51:12 UTC (rev 71167)
+++ Zope/branches/2.9/lib/python/Products/ZCatalog/tests/testCatalog.py 
2006-11-17 20:01:22 UTC (rev 71168)
@@ -177,15 +177,23 @@
 def __nonzero__(self):
 self.fail(__nonzero__() was called)
 
+class FakeTraversalError(KeyError):
+fake traversal exception for testing
+
 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)
+marker = object()
 
+def unrestrictedTraverse(self, path, default=marker):
+result = self.d.get(path, default)
+if result is self.marker:
+raise FakeTraversalError(path)
+return result
+
 class TestZCatalog(unittest.TestCase):
 
 def setUp(self):
@@ -283,7 +291,7 @@
 self._catalog.manage_catalogObject(None, myresponse(), 'URL1', 
urls=('11', '12'))
 
 def testBooleanEvalOn_refreshCatalog_getobject(self):
-# wrap catalog under the fake parent
+# wrap catalog under the fake parent providing unrestrictedTraverse()
 catalog = self._catalog.__of__(fakeparent(self.d))
 # replace entries to test refreshCatalog
 self.d['0'] = dummyLenFail(0, self.fail)
@@ -292,10 +300,27 @@
 catalog.refreshCatalog()
 
 for uid in ('0', '1'):
-rid = self._catalog.getrid(uid)
+rid = catalog.getrid(uid)
 # neither should these
 catalog.getobject(rid)
 
+def 
test_getobject_doesntMaskTraversalErrorsAndDoesntDelegateTo_resolve_url(self):
+# wrap catalog under the fake parent providing unrestrictedTraverse()
+catalog = self._catalog.__of__(fakeparent(self.d))
+# make resolve_url fail if ZCatalog falls back on it
+def resolve_url(path, REQUEST):
+self.fail(.resolve_url() should not be called by .getobject())
+catalog.resolve_url = resolve_url
+
+# traversal should work at first
+rid0 = catalog.getrid('0')
+# lets set it up so the traversal fails
+del self.d['0']
+self.assertRaises(FakeTraversalError, catalog.getobject, rid0, 
REQUEST=object())
+# and if there is a None at the traversal point, that's where it 
should return
+self.d['0'] = None
+self.assertEquals(catalog.getobject(rid0), None)
+
 class dummy(ExtensionClass.Base):
 att1 = 'att1'
 att2 = 'att2'

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


[Zope-Checkins] SVN: Zope/branches/2.10/lib/python/Products/ZCatalog/ revert ZCatalog.getobject() semantics not to mask traversal errors and not to fallback to .resolve_url() when the traversal resul

2006-11-17 Thread Leonardo Rochael Almeida
Log message for revision 71169:
  revert ZCatalog.getobject() semantics not to mask traversal errors and not to 
fallback to .resolve_url() when the traversal result is None
  

Changed:
  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/lib/python/Products/ZCatalog/ZCatalog.py
===
--- Zope/branches/2.10/lib/python/Products/ZCatalog/ZCatalog.py 2006-11-17 
20:01:22 UTC (rev 71168)
+++ Zope/branches/2.10/lib/python/Products/ZCatalog/ZCatalog.py 2006-11-17 
20:11:22 UTC (rev 71169)
@@ -587,12 +587,7 @@
 def getobject(self, rid, REQUEST=None):
 Return a cataloged object given a 'data_record_id_'
 
-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)
-return obj
+return self.aq_parent.unrestrictedTraverse(self.getpath(rid))
 
 def getMetadataForUID(self, uid):
 return the correct metadata given the uid, usually the path

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-17 20:01:22 UTC (rev 71168)
+++ Zope/branches/2.10/lib/python/Products/ZCatalog/tests/testCatalog.py
2006-11-17 20:11:22 UTC (rev 71169)
@@ -177,15 +177,23 @@
 def __nonzero__(self):
 self.fail(__nonzero__() was called)
 
+class FakeTraversalError(KeyError):
+fake traversal exception for testing
+
 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)
+marker = object()
 
+def unrestrictedTraverse(self, path, default=marker):
+result = self.d.get(path, default)
+if result is self.marker:
+raise FakeTraversalError(path)
+return result
+
 class TestZCatalog(unittest.TestCase):
 
 def setUp(self):
@@ -283,7 +291,7 @@
 self._catalog.manage_catalogObject(None, myresponse(), 'URL1', 
urls=('11', '12'))
 
 def testBooleanEvalOn_refreshCatalog_getobject(self):
-# wrap catalog under the fake parent
+# wrap catalog under the fake parent providing unrestrictedTraverse()
 catalog = self._catalog.__of__(fakeparent(self.d))
 # replace entries to test refreshCatalog
 self.d['0'] = dummyLenFail(0, self.fail)
@@ -292,10 +300,27 @@
 catalog.refreshCatalog()
 
 for uid in ('0', '1'):
-rid = self._catalog.getrid(uid)
+rid = catalog.getrid(uid)
 # neither should these
 catalog.getobject(rid)
 
+def 
test_getobject_doesntMaskTraversalErrorsAndDoesntDelegateTo_resolve_url(self):
+# wrap catalog under the fake parent providing unrestrictedTraverse()
+catalog = self._catalog.__of__(fakeparent(self.d))
+# make resolve_url fail if ZCatalog falls back on it
+def resolve_url(path, REQUEST):
+self.fail(.resolve_url() should not be called by .getobject())
+catalog.resolve_url = resolve_url
+
+# traversal should work at first
+rid0 = catalog.getrid('0')
+# lets set it up so the traversal fails
+del self.d['0']
+self.assertRaises(FakeTraversalError, catalog.getobject, rid0, 
REQUEST=object())
+# and if there is a None at the traversal point, that's where it 
should return
+self.d['0'] = None
+self.assertEquals(catalog.getobject(rid0), None)
+
 class dummy(ExtensionClass.Base):
 att1 = 'att1'
 att2 = 'att2'

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


[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/ZCatalog/ revert ZCatalog.getobject() semantics not to mask traversal errors and not to fallback to .resolve_url() when the traversal result is None

2006-11-17 Thread Leonardo Rochael Almeida
Log message for revision 71170:
  revert ZCatalog.getobject() semantics not to mask traversal errors and not to 
fallback to .resolve_url() when the traversal result is None
  

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

-=-
Modified: Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py
===
--- Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py 2006-11-17 20:11:22 UTC 
(rev 71169)
+++ Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py 2006-11-17 20:17:28 UTC 
(rev 71170)
@@ -587,12 +587,7 @@
 def getobject(self, rid, REQUEST=None):
 Return a cataloged object given a 'data_record_id_'
 
-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)
-return obj
+return self.aq_parent.unrestrictedTraverse(self.getpath(rid))
 
 def getMetadataForUID(self, uid):
 return the correct metadata given the uid, usually the path

Modified: Zope/trunk/lib/python/Products/ZCatalog/tests/testCatalog.py
===
--- Zope/trunk/lib/python/Products/ZCatalog/tests/testCatalog.py
2006-11-17 20:11:22 UTC (rev 71169)
+++ Zope/trunk/lib/python/Products/ZCatalog/tests/testCatalog.py
2006-11-17 20:17:28 UTC (rev 71170)
@@ -177,15 +177,23 @@
 def __nonzero__(self):
 self.fail(__nonzero__() was called)
 
+class FakeTraversalError(KeyError):
+fake traversal exception for testing
+
 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)
+marker = object()
 
+def unrestrictedTraverse(self, path, default=marker):
+result = self.d.get(path, default)
+if result is self.marker:
+raise FakeTraversalError(path)
+return result
+
 class TestZCatalog(unittest.TestCase):
 
 def setUp(self):
@@ -283,7 +291,7 @@
 self._catalog.manage_catalogObject(None, myresponse(), 'URL1', 
urls=('11', '12'))
 
 def testBooleanEvalOn_refreshCatalog_getobject(self):
-# wrap catalog under the fake parent
+# wrap catalog under the fake parent providing unrestrictedTraverse()
 catalog = self._catalog.__of__(fakeparent(self.d))
 # replace entries to test refreshCatalog
 self.d['0'] = dummyLenFail(0, self.fail)
@@ -292,10 +300,27 @@
 catalog.refreshCatalog()
 
 for uid in ('0', '1'):
-rid = self._catalog.getrid(uid)
+rid = catalog.getrid(uid)
 # neither should these
 catalog.getobject(rid)
 
+def 
test_getobject_doesntMaskTraversalErrorsAndDoesntDelegateTo_resolve_url(self):
+# wrap catalog under the fake parent providing unrestrictedTraverse()
+catalog = self._catalog.__of__(fakeparent(self.d))
+# make resolve_url fail if ZCatalog falls back on it
+def resolve_url(path, REQUEST):
+self.fail(.resolve_url() should not be called by .getobject())
+catalog.resolve_url = resolve_url
+
+# traversal should work at first
+rid0 = catalog.getrid('0')
+# lets set it up so the traversal fails
+del self.d['0']
+self.assertRaises(FakeTraversalError, catalog.getobject, rid0, 
REQUEST=object())
+# and if there is a None at the traversal point, that's where it 
should return
+self.d['0'] = None
+self.assertEquals(catalog.getobject(rid0), None)
+
 class dummy(ExtensionClass.Base):
 att1 = 'att1'
 att2 = 'att2'

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


[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/ fix #2235 for real now

2006-11-14 Thread Leonardo Rochael Almeida
Log message for revision 71127:
  fix #2235 for real now
  

Changed:
  U   Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
  U   Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/ZCatalog.py
  U   
Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/tests/testCatalog.py

-=-
Modified: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
===
--- Zope/branches/Zope-2_8-branch/doc/CHANGES.txt   2006-11-15 05:32:07 UTC 
(rev 71126)
+++ Zope/branches/Zope-2_8-branch/doc/CHANGES.txt   2006-11-15 07:48:38 UTC 
(rev 71127)
@@ -8,8 +8,10 @@
 
 Bugs fixed
 
-  - Collector #2235: ZCatalog.manage_catalogObject was triggering __len__
-of objects that implement it, like containers.
+  - Collector #2235: A number of ZCatalog methods were doing boolean
+evaluation of objects that implemented __len__ instead of checking
+them against None. Replace a number of if not obj with
+if obj is not None.
 
   - Fix yet another resTructuredText glitch, and add tests (test
 backported from 2.9, which was not in fact vulnerable).

Modified: Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/ZCatalog.py
===
--- Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/ZCatalog.py  
2006-11-15 05:32:07 UTC (rev 71126)
+++ Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/ZCatalog.py  
2006-11-15 07:48:38 UTC (rev 71127)
@@ -232,7 +232,7 @@
 
 for url in urls:
 obj = self.resolve_path(url)
-if obj is not None:
+if obj is None:
 obj = self.resolve_url(url, REQUEST)
 if obj is not None:
 self.catalog_object(obj, url)
@@ -297,7 +297,7 @@
 p = paths[i]
 obj = self.resolve_path(p)
 
-if not obj and hasattr(self, 'REQUEST'):
+if obj is None and hasattr(self, 'REQUEST'):
 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/Zope-2_8-branch/lib/python/Products/ZCatalog/tests/testCatalog.py
===
--- 
Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/tests/testCatalog.py 
2006-11-15 05:32:07 UTC (rev 71126)
+++ 
Zope/branches/Zope-2_8-branch/lib/python/Products/ZCatalog/tests/testCatalog.py 
2006-11-15 07:48:38 UTC (rev 71127)
@@ -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,28 +272,30 @@
 result = self._catalog(title='')
 self.assertEquals(1, len(result))
 
-def test_manage_catalogObject_does_not_trigger_boolean_eval(self):
-# make objects with __len__ and __nonzero__
-class mydummy1:
-def __init__(self, fail):
-self.fail = fail
-def __len__(self):
-self.fail(__len__() was called)
-class mydummy2:
-def __init__(self, fail):
-self.fail = fail
-def __nonzero__(self):
-self.fail(__nonzero__() was called)
-# store them to be found by the catalog
-self.d['0'] = mydummy1(self.fail)
-