[Zope-Checkins] SVN: Zope/trunk/ Simpler, faster implementation of DocumentTemplate.DT_Var.newline_to_br(), with tests.

2008-11-18 Thread Paul Winkler
Log message for revision 93099:
  Simpler, faster implementation of DocumentTemplate.DT_Var.newline_to_br(), 
with tests.

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/DocumentTemplate/DT_Var.py
  A   Zope/trunk/lib/python/DocumentTemplate/tests/test_DT_Var.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===
--- Zope/trunk/doc/CHANGES.txt  2008-11-18 20:15:21 UTC (rev 93098)
+++ Zope/trunk/doc/CHANGES.txt  2008-11-18 20:27:52 UTC (rev 93099)
@@ -520,6 +520,9 @@
   - Added lib/python/webdav/litmus-results.txt explaining current
 test results from the litmus WebDAV torture test.
 
+  - DocumentTemplate.DT_Var.newline_to_br(): Simpler, faster 
implementation.
+
+
   Zope 2.10.0 beta 1 (2006/05/30)
 
 Restructuring

Modified: Zope/trunk/lib/python/DocumentTemplate/DT_Var.py
===
--- Zope/trunk/lib/python/DocumentTemplate/DT_Var.py2008-11-18 20:15:21 UTC 
(rev 93098)
+++ Zope/trunk/lib/python/DocumentTemplate/DT_Var.py2008-11-18 20:27:52 UTC 
(rev 93099)
@@ -358,8 +358,8 @@
 # quoted later on anyway.
 if isinstance(v, TaintedString): v = v.quoted()
 v=ustr(v)
-if v.find('\r') = 0: v=''.join(v.split('\r'))
-if v.find('\n') = 0: v='br /\n'.join(v.split('\n'))
+v = v.replace('\r', '')
+v = v.replace('\n', 'br /\n')
 return v
 
 def whole_dollars(v, name='(Unknown name)', md={}):

Added: Zope/trunk/lib/python/DocumentTemplate/tests/test_DT_Var.py
===
--- Zope/trunk/lib/python/DocumentTemplate/tests/test_DT_Var.py 
(rev 0)
+++ Zope/trunk/lib/python/DocumentTemplate/tests/test_DT_Var.py 2008-11-18 
20:27:52 UTC (rev 93099)
@@ -0,0 +1,70 @@
+##
+#
+# Copyright (c) 2008 Zope Corporation 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.
+#
+##
+Tests for functions and classes in DT_Var.
+
+$Id$
+
+
+import unittest, doctest
+from DocumentTemplate import DT_Var
+
+class TestNewlineToBr(doctest.DocTestCase):
+
+def test_newline_to_br(self):
+r
+newline_to_br should work identically with either DOS-style or
+Unix-style newlines.
+
+ text = '''
+... line one
+... line two
+...
+... line three
+... '''
+ print DT_Var.newline_to_br(text)
+br /
+line onebr /
+line twobr /
+br /
+line threebr /
+BLANKLINE
+
+ dos = text.replace('\n', '\r\n')
+ DT_Var.newline_to_br(text) == DT_Var.newline_to_br(dos)
+True
+
+
+
+def test_newline_to_br_tainted(self):
+
+ text = '''
+... liline one/li
+... liline two/li
+... '''
+ from ZPublisher.TaintedString import TaintedString
+ tainted = TaintedString(text)
+ print DT_Var.newline_to_br(tainted)
+br /
+lt;ligt;line onelt;/ligt;br /
+lt;ligt;line twolt;/ligt;br /
+BLANKLINE
+
+
+
+def test_suite():
+suite = unittest.TestSuite()
+suite.addTest(doctest.DocTestSuite())
+return suite
+
+if __name__ == '__main__':
+unittest.main(defaultTest='test_suite')


Property changes on: Zope/trunk/lib/python/DocumentTemplate/tests/test_DT_Var.py
___
Added: svn:keywords
   + Author Date Revision

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


[Zope-Checkins] SVN: Zope/trunk/ Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct hour

2008-09-07 Thread Paul Winkler
Log message for revision 90920:
  Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct 
hour

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/DateTime/DateTime.py
  U   Zope/trunk/lib/python/DateTime/tests/testDateTime.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===
--- Zope/trunk/doc/CHANGES.txt  2008-09-07 02:49:58 UTC (rev 90919)
+++ Zope/trunk/doc/CHANGES.txt  2008-09-07 19:50:10 UTC (rev 90920)
@@ -207,6 +207,9 @@
 
 Bugs Fixed
 
+  - Launchpad #267545: DateTime(DateTime()) now preserves the
+correct hour
+
   - Launchpad #262313: respect the 'Expand macros when editing' flag
 when editing a page template through the ZMI
 

Modified: Zope/trunk/lib/python/DateTime/DateTime.py
===
--- Zope/trunk/lib/python/DateTime/DateTime.py  2008-09-07 02:49:58 UTC (rev 
90919)
+++ Zope/trunk/lib/python/DateTime/DateTime.py  2008-09-07 19:50:10 UTC (rev 
90920)
@@ -586,11 +586,8 @@
 DateTime instance.
 
 t = arg.timeTime()
-tz = arg.timezone()
-ms = (t - math.floor(t))
 s,d = _calcSD(t)
-yr,mo,dy,hr,mn,sc = gmtime(t)[:6]
-sc = sc + ms
+yr,mo,dy,hr,mn,sc,tz = arg.parts()
 
 elif isinstance(arg, datetime):
 
yr,mo,dy,hr,mn,sc,numerictz,tznaive=self._parse_iso8601_preserving_tznaive(arg.isoformat())

Modified: Zope/trunk/lib/python/DateTime/tests/testDateTime.py
===
--- Zope/trunk/lib/python/DateTime/tests/testDateTime.py2008-09-07 
02:49:58 UTC (rev 90919)
+++ Zope/trunk/lib/python/DateTime/tests/testDateTime.py2008-09-07 
19:50:10 UTC (rev 90920)
@@ -401,8 +401,10 @@
 def testCopyConstructor(self):
 d = DateTime('2004/04/04')
 self.assertEqual(DateTime(d), d)
-d = DateTime('1999/04/12')
-self.assertEqual(DateTime(d), d)
+self.assertEqual(str(DateTime(d)), str(d))
+d2 = DateTime('1999/04/12 01:00:00')
+self.assertEqual(DateTime(d2), d2)
+self.assertEqual(str(DateTime(d2)), str(d2))
 
 def testCopyConstructorPreservesTimezone(self):
 # test for https://bugs.launchpad.net/zope2/+bug/27
@@ -413,8 +415,10 @@
 self.assertEqual(DateTime(d).timezone(), d.timezone())
 d2 = DateTime('2008/04/25 12:00:00 EST')
 self.assertEqual(DateTime(d2).timezone(), d2.timezone())
+self.assertEqual(str(DateTime(d2)), str(d2))
 d3 = DateTime('2008/04/25 12:00:00 PST')
 self.assertEqual(DateTime(d3).timezone(), d3.timezone())
+self.assertEqual(str(DateTime(d3)), str(d3))
 
 
 def testRFC822(self):

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


[Zope-Checkins] SVN: Zope/branches/2.11/ Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct hour

2008-09-07 Thread Paul Winkler
Log message for revision 90921:
  Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct 
hour

Changed:
  U   Zope/branches/2.11/doc/CHANGES.txt
  U   Zope/branches/2.11/lib/python/DateTime/DateTime.py
  U   Zope/branches/2.11/lib/python/DateTime/tests/testDateTime.py

-=-
Modified: Zope/branches/2.11/doc/CHANGES.txt
===
--- Zope/branches/2.11/doc/CHANGES.txt  2008-09-07 19:50:10 UTC (rev 90920)
+++ Zope/branches/2.11/doc/CHANGES.txt  2008-09-07 19:51:10 UTC (rev 90921)
@@ -16,6 +16,9 @@
 
   - integrated Hotfix-2008-08-12
 
+  - Launchpad #267545: DateTime(DateTime()) now preserves the
+correct hour
+
   - Launchpad #262313: respect the 'Expand macros when editing' flag
 when editing a page template through the ZMI
 

Modified: Zope/branches/2.11/lib/python/DateTime/DateTime.py
===
--- Zope/branches/2.11/lib/python/DateTime/DateTime.py  2008-09-07 19:50:10 UTC 
(rev 90920)
+++ Zope/branches/2.11/lib/python/DateTime/DateTime.py  2008-09-07 19:51:10 UTC 
(rev 90921)
@@ -586,11 +586,8 @@
 DateTime instance.
 
 t = arg.timeTime()
-tz = arg.timezone()
-ms = (t - math.floor(t))
 s,d = _calcSD(t)
-yr,mo,dy,hr,mn,sc = gmtime(t)[:6]
-sc = sc + ms
+yr,mo,dy,hr,mn,sc,tz = arg.parts()
 
 elif isinstance(arg, datetime):
 
yr,mo,dy,hr,mn,sc,numerictz,tznaive=self._parse_iso8601_preserving_tznaive(arg.isoformat())

Modified: Zope/branches/2.11/lib/python/DateTime/tests/testDateTime.py
===
--- Zope/branches/2.11/lib/python/DateTime/tests/testDateTime.py
2008-09-07 19:50:10 UTC (rev 90920)
+++ Zope/branches/2.11/lib/python/DateTime/tests/testDateTime.py
2008-09-07 19:51:10 UTC (rev 90921)
@@ -401,8 +401,10 @@
 def testCopyConstructor(self):
 d = DateTime('2004/04/04')
 self.assertEqual(DateTime(d), d)
-d = DateTime('1999/04/12')
-self.assertEqual(DateTime(d), d)
+self.assertEqual(str(DateTime(d)), str(d))
+d2 = DateTime('1999/04/12 01:00:00')
+self.assertEqual(DateTime(d2), d2)
+self.assertEqual(str(DateTime(d2)), str(d2))
 
 def testCopyConstructorPreservesTimezone(self):
 # test for https://bugs.launchpad.net/zope2/+bug/27
@@ -413,8 +415,10 @@
 self.assertEqual(DateTime(d).timezone(), d.timezone())
 d2 = DateTime('2008/04/25 12:00:00 EST')
 self.assertEqual(DateTime(d2).timezone(), d2.timezone())
+self.assertEqual(str(DateTime(d2)), str(d2))
 d3 = DateTime('2008/04/25 12:00:00 PST')
 self.assertEqual(DateTime(d3).timezone(), d3.timezone())
+self.assertEqual(str(DateTime(d3)), str(d3))
 
 
 def testRFC822(self):

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


[Zope-Checkins] SVN: Zope/branches/2.10/ Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct hour

2008-09-07 Thread Paul Winkler
Log message for revision 90922:
  Fix for launchpad #267545: DateTime(DateTime()) should preserve the correct 
hour

Changed:
  U   Zope/branches/2.10/doc/CHANGES.txt
  U   Zope/branches/2.10/lib/python/DateTime/DateTime.py
  U   Zope/branches/2.10/lib/python/DateTime/tests/testDateTime.py

-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===
--- Zope/branches/2.10/doc/CHANGES.txt  2008-09-07 19:51:10 UTC (rev 90921)
+++ Zope/branches/2.10/doc/CHANGES.txt  2008-09-07 19:52:37 UTC (rev 90922)
@@ -24,6 +24,9 @@
 
   - integrated Hotfix-2008-08-12
 
+  - Launchpad #267545: DateTime(DateTime()) now preserves the
+correct hour
+
   - Launchpad #262313: respect the 'Expand macros when editing' flag
 when editing a page template through the ZMI
 

Modified: Zope/branches/2.10/lib/python/DateTime/DateTime.py
===
--- Zope/branches/2.10/lib/python/DateTime/DateTime.py  2008-09-07 19:51:10 UTC 
(rev 90921)
+++ Zope/branches/2.10/lib/python/DateTime/DateTime.py  2008-09-07 19:52:37 UTC 
(rev 90922)
@@ -704,11 +704,8 @@
 if isinstance(arg, DateTime):
  Construct a new DateTime instance from a given DateTime 
instance 
 t = arg.timeTime()
-tz = arg.timezone()
-ms = (t - math.floor(t))
 s,d = _calcSD(t)
-yr,mo,dy,hr,mn,sc = gmtime(t)[:6]
-sc = sc + ms
+yr,mo,dy,hr,mn,sc,tz = arg.parts()
 
 elif isinstance(arg, (unicode, str)) and arg.lower() in 
self._tzinfo._zidx:
 # Current time, to be displayed in specified timezone

Modified: Zope/branches/2.10/lib/python/DateTime/tests/testDateTime.py
===
--- Zope/branches/2.10/lib/python/DateTime/tests/testDateTime.py
2008-09-07 19:51:10 UTC (rev 90921)
+++ Zope/branches/2.10/lib/python/DateTime/tests/testDateTime.py
2008-09-07 19:52:37 UTC (rev 90922)
@@ -296,8 +296,10 @@
 def testCopyConstructor(self):
 d = DateTime('2004/04/04')
 self.assertEqual(DateTime(d), d)
-d = DateTime('1999/04/12')
-self.assertEqual(DateTime(d), d)
+self.assertEqual(str(DateTime(d)), str(d))
+d2 = DateTime('1999/04/12 01:00:00')
+self.assertEqual(DateTime(d2), d2)
+self.assertEqual(str(DateTime(d2)), str(d2))
 
 def testCopyConstructorPreservesTimezone(self):
 # test for https://bugs.launchpad.net/zope2/+bug/27
@@ -308,8 +310,10 @@
 self.assertEqual(DateTime(d).timezone(), d.timezone())
 d2 = DateTime('2008/04/25 12:00:00 EST')
 self.assertEqual(DateTime(d2).timezone(), d2.timezone())
+self.assertEqual(str(DateTime(d2)), str(d2))
 d3 = DateTime('2008/04/25 12:00:00 PST')
 self.assertEqual(DateTime(d3).timezone(), d3.timezone())
+self.assertEqual(str(DateTime(d3)), str(d3))
 
 
 def testRFC822(self):

___
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/PageTemplates/PageTemplateFile.py Merge r41209 from trunk (use proper call signature for logging, not zLOG)

2008-06-03 Thread Paul Winkler
Log message for revision 87132:
  Merge r41209 from trunk (use proper call signature for logging, not zLOG)
  

Changed:
  U   Zope/branches/2.9/lib/python/Products/PageTemplates/PageTemplateFile.py

-=-
Modified: 
Zope/branches/2.9/lib/python/Products/PageTemplates/PageTemplateFile.py
===
--- Zope/branches/2.9/lib/python/Products/PageTemplates/PageTemplateFile.py 
2008-06-03 17:42:05 UTC (rev 87131)
+++ Zope/branches/2.9/lib/python/Products/PageTemplates/PageTemplateFile.py 
2008-06-03 22:15:18 UTC (rev 87132)
@@ -149,7 +149,7 @@
 self.pt_edit(text, t)
 self._cook()
 if self._v_errors:
-LOG.error('Error in template', '\n'.join(self._v_errors))
+LOG.error('Error in template %s' % '\n'.join(self._v_errors))
 return
 self._v_last_read = mtime
 

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


[Zope-Checkins] SVN: Products.Five/branches/1.4/CHANGES.txt Fix release dates of 1.4.4 and 1.4.3 in CHANGES.txt. Commit logs reveal that they were off by 1 year

2008-05-29 Thread Paul Winkler
Log message for revision 87037:
  Fix release dates of 1.4.4 and 1.4.3 in CHANGES.txt. Commit logs reveal that 
they were off by 1 year

Changed:
  U   Products.Five/branches/1.4/CHANGES.txt

-=-
Modified: Products.Five/branches/1.4/CHANGES.txt
===
--- Products.Five/branches/1.4/CHANGES.txt  2008-05-29 15:56:39 UTC (rev 
87036)
+++ Products.Five/branches/1.4/CHANGES.txt  2008-05-29 16:14:45 UTC (rev 
87037)
@@ -12,7 +12,7 @@
   that happened during startup of zope.
 
 
-Five 1.4.4 (2006-07-31)
+Five 1.4.4 (2007-07-31)
 ===
 
 Bugfixes
@@ -23,7 +23,7 @@
 
   This change requires Zope 2.9.8 or higher.
 
-Five 1.4.3 (2006-06-25)
+Five 1.4.3 (2007-06-25)
 ===
 
 Bugfixes

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


[Zope-Checkins] SVN: Zope/branches/slinkp-zopectl-exitcode-143813/ Making a branch to fix https://bugs.launchpad.net/zope2/+bug/143813

2008-05-04 Thread Paul Winkler
Log message for revision 85724:
  Making a branch to fix https://bugs.launchpad.net/zope2/+bug/143813
  

Changed:
  A   Zope/branches/slinkp-zopectl-exitcode-143813/

-=-
Copied: Zope/branches/slinkp-zopectl-exitcode-143813 (from rev 85723, 
Zope/trunk)

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


[Zope-Checkins] SVN: Zope/branches/slinkp-zopectl-exitcode-143813/lib/python/Zope2/Startup/zopectl.py Fixes bug 143813: zopectl should exit non-zero if child processes fail.

2008-05-04 Thread Paul Winkler
Log message for revision 85725:
  Fixes bug 143813: zopectl should exit non-zero if child processes fail.

Changed:
  U   
Zope/branches/slinkp-zopectl-exitcode-143813/lib/python/Zope2/Startup/zopectl.py

-=-
Modified: 
Zope/branches/slinkp-zopectl-exitcode-143813/lib/python/Zope2/Startup/zopectl.py
===
--- 
Zope/branches/slinkp-zopectl-exitcode-143813/lib/python/Zope2/Startup/zopectl.py
2008-04-25 16:07:13 UTC (rev 85724)
+++ 
Zope/branches/slinkp-zopectl-exitcode-143813/lib/python/Zope2/Startup/zopectl.py
2008-04-25 17:02:19 UTC (rev 85725)
@@ -147,6 +147,8 @@
 
 class ZopeCmd(ZDCmd):
 
+_exitstatus = 0
+
 def _get_override(self, opt, name, svalue=None, flag=0):
 # Suppress the config file, and pass all configuration via the
 # command line.  This avoids needing to specialize the zdrun
@@ -265,7 +267,7 @@
 cmd += '[sys.argv.append(x) for x in %s];' % argv
 cmd += 'import Zope2; app=Zope2.app(); execfile(\'%s\')' % script
 cmdline = self.get_startup_cmd(self.options.python, cmd)
-os.system(cmdline)
+self._exitstatus = os.system(cmdline)
 
 def help_run(self):
 print run script [args] -- run a Python script with the Zope 
@@ -335,10 +337,11 @@
 # Parent process running (execv replaces process in child
 while True:
 try:
-os.waitpid(pid, 0)
+pid, status = os.waitpid(pid, 0)
 except (OSError, KeyboardInterrupt):
 continue
 else:
+self._exitstatus = status
 break
 
 def help_test(self):
@@ -364,6 +367,8 @@
 print program:,  .join(options.program)
 c.do_status()
 c.cmdloop()
+else:
+return min(c._exitstatus, 1)
 
 def _ignoreSIGCHLD(*unused):
 while 1:
@@ -393,4 +398,5 @@
 # SIGCHILD is unset, just don't bother registering a SIGCHILD
 # signal handler at all.
 signal.signal(signal.SIGCHLD, _ignoreSIGCHLD)
-main()
+exitstatus = main()
+sys.exit(exitstatus)

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


[Zope-Checkins] SVN: Zope/branches/2.11/ Fixes bug 143813: zopectl should exit non-zero if child processes fail.

2008-05-04 Thread Paul Winkler
Log message for revision 85727:
  Fixes bug 143813: zopectl should exit non-zero if child processes fail.

Changed:
  U   Zope/branches/2.11/doc/CHANGES.txt
  U   Zope/branches/2.11/lib/python/Zope2/Startup/zopectl.py

-=-
Modified: Zope/branches/2.11/doc/CHANGES.txt
===
--- Zope/branches/2.11/doc/CHANGES.txt  2008-04-25 17:07:36 UTC (rev 85726)
+++ Zope/branches/2.11/doc/CHANGES.txt  2008-04-25 18:37:03 UTC (rev 85727)
@@ -8,6 +8,9 @@
 
 Bugs Fixed
 
+  - Launchpad #143813: zopectl now exits non-zero when
+child processes fail.
+
   - Products.Five: Resynced browser.adding with zope.app.container.
 This fixes some minor bugs and removes deprecated code.
 

Modified: Zope/branches/2.11/lib/python/Zope2/Startup/zopectl.py
===
--- Zope/branches/2.11/lib/python/Zope2/Startup/zopectl.py  2008-04-25 
17:07:36 UTC (rev 85726)
+++ Zope/branches/2.11/lib/python/Zope2/Startup/zopectl.py  2008-04-25 
18:37:03 UTC (rev 85727)
@@ -147,6 +147,8 @@
 
 class ZopeCmd(ZDCmd):
 
+_exitstatus = 0
+
 def _get_override(self, opt, name, svalue=None, flag=0):
 # Suppress the config file, and pass all configuration via the
 # command line.  This avoids needing to specialize the zdrun
@@ -265,7 +267,7 @@
 cmd += '[sys.argv.append(x) for x in %s];' % argv
 cmd += 'import Zope2; app=Zope2.app(); execfile(\'%s\')' % script
 cmdline = self.get_startup_cmd(self.options.python, cmd)
-os.system(cmdline)
+self._exitstatus = os.system(cmdline)
 
 def help_run(self):
 print run script [args] -- run a Python script with the Zope 
@@ -335,10 +337,11 @@
 # Parent process running (execv replaces process in child
 while True:
 try:
-os.waitpid(pid, 0)
+pid, status = os.waitpid(pid, 0)
 except (OSError, KeyboardInterrupt):
 continue
 else:
+self._exitstatus = status
 break
 
 def help_test(self):
@@ -364,6 +367,8 @@
 print program:,  .join(options.program)
 c.do_status()
 c.cmdloop()
+else:
+return min(c._exitstatus, 1)
 
 def _ignoreSIGCHLD(*unused):
 while 1:
@@ -393,4 +398,5 @@
 # SIGCHILD is unset, just don't bother registering a SIGCHILD
 # signal handler at all.
 signal.signal(signal.SIGCHLD, _ignoreSIGCHLD)
-main()
+exitstatus = main()
+sys.exit(exitstatus)

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


[Zope-Checkins] SVN: Zope/branches/slinkp-datetime-200007/ branch for fixing https://bugs.launchpad.net/zope2/+bug/200007

2008-05-04 Thread Paul Winkler
Log message for revision 85733:
  branch for fixing https://bugs.launchpad.net/zope2/+bug/27
  

Changed:
  A   Zope/branches/slinkp-datetime-27/

-=-
Copied: Zope/branches/slinkp-datetime-27 (from rev 85732, Zope/trunk)

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


[Zope-Checkins] SVN: Zope/branches/slinkp-datetime-200007/lib/python/DateTime/ Fix for launchpad #200007: DateTime() surprisingly changes timezone if passed a DateTime instance.

2008-05-04 Thread Paul Winkler
Log message for revision 85734:
  Fix for launchpad #27: DateTime() surprisingly changes timezone if passed 
a DateTime instance.

Changed:
  U   Zope/branches/slinkp-datetime-27/lib/python/DateTime/DateTime.py
  U   
Zope/branches/slinkp-datetime-27/lib/python/DateTime/tests/testDateTime.py

-=-
Modified: Zope/branches/slinkp-datetime-27/lib/python/DateTime/DateTime.py
===
--- Zope/branches/slinkp-datetime-27/lib/python/DateTime/DateTime.py
2008-04-25 20:22:51 UTC (rev 85733)
+++ Zope/branches/slinkp-datetime-27/lib/python/DateTime/DateTime.py
2008-04-25 20:58:04 UTC (rev 85734)
@@ -68,7 +68,7 @@
   (?:-? # one optional dash
(?:  # followed by:
 (?Pyear_day\d\d\d #  three digits year day
- (?!\d))#  when there's no fourth digit
+ (?!\d))#  when there is no fourth digit
|# or:
 W   #  one W
 (?Pweek\d\d)  #  two digits week
@@ -586,12 +586,11 @@
 DateTime instance.
 
 t = arg.timeTime()
-lt = safelocaltime(t)
-tz = self.localZone(lt)
+tz = arg.timezone()
 ms = (t - math.floor(t))
 s,d = _calcSD(t)
-yr,mo,dy,hr,mn,sc=lt[:6]
-sc=sc+ms
+yr,mo,dy,hr,mn,sc = gmtime(t)[:6]
+sc = sc + ms
 
 elif isinstance(arg, datetime):
 
yr,mo,dy,hr,mn,sc,numerictz,tznaive=self._parse_iso8601_preserving_tznaive(arg.isoformat())

Modified: 
Zope/branches/slinkp-datetime-27/lib/python/DateTime/tests/testDateTime.py
===
--- 
Zope/branches/slinkp-datetime-27/lib/python/DateTime/tests/testDateTime.py  
2008-04-25 20:22:51 UTC (rev 85733)
+++ 
Zope/branches/slinkp-datetime-27/lib/python/DateTime/tests/testDateTime.py  
2008-04-25 20:58:04 UTC (rev 85734)
@@ -386,6 +386,19 @@
 d = DateTime('1999/04/12')
 self.assertEqual(DateTime(d), d)
 
+def testCopyConstructorPreservesTimezone(self):
+# test for https://bugs.launchpad.net/zope2/+bug/27
+# This always worked in the local timezone, so we need at least
+# two tests with different zones to be sure at least one of them
+# is not local.
+d = DateTime('2004/04/04')
+self.assertEqual(DateTime(d).timezone(), d.timezone())
+d2 = DateTime('2008/04/25 12:00:00 EST')
+self.assertEqual(DateTime(d2).timezone(), d2.timezone())
+d3 = DateTime('2008/04/25 12:00:00 PST')
+self.assertEqual(DateTime(d3).timezone(), d3.timezone())
+
+
 def testRFC822(self):
 # rfc822 conversion
 dt = DateTime('2002-05-02T08:00:00+00:00')

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


[Zope-Checkins] SVN: Zope/trunk/lib/python/DateTime/ Merged the slinkp-datetime-200007 branch: fix the DateTime(anotherDateTime) constructor to preserve timezones.

2008-04-28 Thread Paul Winkler
Log message for revision 85830:
  Merged the slinkp-datetime-27 branch: fix the DateTime(anotherDateTime) 
constructor to preserve timezones.

Changed:
  U   Zope/trunk/lib/python/DateTime/DateTime.py
  U   Zope/trunk/lib/python/DateTime/tests/testDateTime.py

-=-
Modified: Zope/trunk/lib/python/DateTime/DateTime.py
===
--- Zope/trunk/lib/python/DateTime/DateTime.py  2008-04-28 19:31:09 UTC (rev 
85829)
+++ Zope/trunk/lib/python/DateTime/DateTime.py  2008-04-28 20:23:11 UTC (rev 
85830)
@@ -68,7 +68,7 @@
   (?:-? # one optional dash
(?:  # followed by:
 (?Pyear_day\d\d\d #  three digits year day
- (?!\d))#  when there's no fourth digit
+ (?!\d))#  when there is no fourth digit
|# or:
 W   #  one W
 (?Pweek\d\d)  #  two digits week
@@ -586,12 +586,11 @@
 DateTime instance.
 
 t = arg.timeTime()
-lt = safelocaltime(t)
-tz = self.localZone(lt)
+tz = arg.timezone()
 ms = (t - math.floor(t))
 s,d = _calcSD(t)
-yr,mo,dy,hr,mn,sc=lt[:6]
-sc=sc+ms
+yr,mo,dy,hr,mn,sc = gmtime(t)[:6]
+sc = sc + ms
 
 elif isinstance(arg, datetime):
 
yr,mo,dy,hr,mn,sc,numerictz,tznaive=self._parse_iso8601_preserving_tznaive(arg.isoformat())

Modified: Zope/trunk/lib/python/DateTime/tests/testDateTime.py
===
--- Zope/trunk/lib/python/DateTime/tests/testDateTime.py2008-04-28 
19:31:09 UTC (rev 85829)
+++ Zope/trunk/lib/python/DateTime/tests/testDateTime.py2008-04-28 
20:23:11 UTC (rev 85830)
@@ -386,6 +386,19 @@
 d = DateTime('1999/04/12')
 self.assertEqual(DateTime(d), d)
 
+def testCopyConstructorPreservesTimezone(self):
+# test for https://bugs.launchpad.net/zope2/+bug/27
+# This always worked in the local timezone, so we need at least
+# two tests with different zones to be sure at least one of them
+# is not local.
+d = DateTime('2004/04/04')
+self.assertEqual(DateTime(d).timezone(), d.timezone())
+d2 = DateTime('2008/04/25 12:00:00 EST')
+self.assertEqual(DateTime(d2).timezone(), d2.timezone())
+d3 = DateTime('2008/04/25 12:00:00 PST')
+self.assertEqual(DateTime(d3).timezone(), d3.timezone())
+
+
 def testRFC822(self):
 # rfc822 conversion
 dt = DateTime('2002-05-02T08:00:00+00:00')

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


[Zope-Checkins] SVN: Zope/branches/2.9/ Merged the slinkp-datetime-200007 branch: fix the DateTime(anotherDateTime) constructor to preserve timezones.

2008-04-28 Thread Paul Winkler
Log message for revision 85837:
  Merged the slinkp-datetime-27 branch: fix the DateTime(anotherDateTime) 
constructor to preserve timezones.

Changed:
  U   Zope/branches/2.9/configure
  U   Zope/branches/2.9/doc/CHANGES.txt
  U   Zope/branches/2.9/lib/python/DateTime/DateTime.py
  U   Zope/branches/2.9/lib/python/DateTime/tests/testDateTime.py

-=-
Modified: Zope/branches/2.9/configure
===
--- Zope/branches/2.9/configure 2008-04-28 21:19:27 UTC (rev 85836)
+++ Zope/branches/2.9/configure 2008-04-28 21:22:09 UTC (rev 85837)
@@ -12,13 +12,13 @@
 
 # Place the optimal target version number for Zope (as returned by sys.version)
 # below
-TARGET=2.4.4
+TARGET=2.4.5
 
 # Order a list of acceptable python version numbers (as returned by
 # sys.version) below in best to worst order, not including the
 # target version.  Up to six acceptable python versions are allowed.
 # Do not include the target version number in this list!
-ACCEPTABLE=2.4.2 2.4.3
+ACCEPTABLE=2.4.4 2.4.2 2.4.3
 
 # provide the executable names for all the acceptable versions
 # (and the target version) below

Modified: Zope/branches/2.9/doc/CHANGES.txt
===
--- Zope/branches/2.9/doc/CHANGES.txt   2008-04-28 21:19:27 UTC (rev 85836)
+++ Zope/branches/2.9/doc/CHANGES.txt   2008-04-28 21:22:09 UTC (rev 85837)
@@ -8,6 +8,9 @@
 
Bugs fixed
 
+  - Launchpad #27: DateTime(anotherDateTime) now preserves the
+timezone.
+
   - Launchpad #143813: zopectl now exits non-zero when
 child processes fail.
 

Modified: Zope/branches/2.9/lib/python/DateTime/DateTime.py
===
--- Zope/branches/2.9/lib/python/DateTime/DateTime.py   2008-04-28 21:19:27 UTC 
(rev 85836)
+++ Zope/branches/2.9/lib/python/DateTime/DateTime.py   2008-04-28 21:22:09 UTC 
(rev 85837)
@@ -712,12 +712,11 @@
 if isinstance(arg, DateTime):
  Construct a new DateTime instance from a given DateTime 
instance 
 t = arg.timeTime()
-lt = safelocaltime(t)
-tz = self.localZone(lt)
+tz = arg.timezone()
 ms = (t - math.floor(t))
 s,d = _calcSD(t)
-yr,mo,dy,hr,mn,sc=lt[:6]
-sc=sc+ms
+yr,mo,dy,hr,mn,sc = gmtime(t)[:6]
+sc = sc + ms
 
 elif isinstance(arg, (unicode, str)) and arg.lower() in 
self._tzinfo._zidx:
 # Current time, to be displayed in specified timezone

Modified: Zope/branches/2.9/lib/python/DateTime/tests/testDateTime.py
===
--- Zope/branches/2.9/lib/python/DateTime/tests/testDateTime.py 2008-04-28 
21:19:27 UTC (rev 85836)
+++ Zope/branches/2.9/lib/python/DateTime/tests/testDateTime.py 2008-04-28 
21:22:09 UTC (rev 85837)
@@ -299,6 +299,19 @@
 d = DateTime('1999/04/12')
 self.assertEqual(DateTime(d), d)
 
+def testCopyConstructorPreservesTimezone(self):
+# test for https://bugs.launchpad.net/zope2/+bug/27
+# This always worked in the local timezone, so we need at least
+# two tests with different zones to be sure at least one of them
+# is not local.
+d = DateTime('2004/04/04')
+self.assertEqual(DateTime(d).timezone(), d.timezone())
+d2 = DateTime('2008/04/25 12:00:00 EST')
+self.assertEqual(DateTime(d2).timezone(), d2.timezone())
+d3 = DateTime('2008/04/25 12:00:00 PST')
+self.assertEqual(DateTime(d3).timezone(), d3.timezone())
+
+
 def testRFC822(self):
 '''rfc822 conversion'''
 dt = DateTime('2002-05-02T08:00:00+00:00')

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


[Zope-Checkins] SVN: Zope/branches/slinkp-1447-httpcache-fix-branch/ making a branch to fix collector 1447,

2006-05-04 Thread Paul Winkler
Log message for revision 67975:
  making a branch to fix collector 1447, 
  AcceleratedHTTPCacheManager doesn't PURGE correctly for virtual hosts
  

Changed:
  A   Zope/branches/slinkp-1447-httpcache-fix-branch/

-=-
Copied: Zope/branches/slinkp-1447-httpcache-fix-branch (from rev 67974, 
Zope/trunk)

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


[Zope-Checkins] SVN: Zope/branches/slinkp-1447-httpcache-fix-branch/lib/python/Products/StandardCacheManagers/ Fixes and unit tests for http://www.zope.org/Collectors/Zope/1447:

2006-05-04 Thread Paul Winkler
Log message for revision 67976:
  Fixes and unit tests for http://www.zope.org/Collectors/Zope/1447:
  when editing content on a virtual-hosted zope, changes will purge
  correctly.
  Also simplified the test framework (no more need to launch an
  HTTP server).
  
  

Changed:
  U   
Zope/branches/slinkp-1447-httpcache-fix-branch/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
  U   
Zope/branches/slinkp-1447-httpcache-fix-branch/lib/python/Products/StandardCacheManagers/tests/test_AcceleratedHTTPCacheManager.py

-=-
Modified: 
Zope/branches/slinkp-1447-httpcache-fix-branch/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
===
--- 
Zope/branches/slinkp-1447-httpcache-fix-branch/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
 2006-05-05 01:41:05 UTC (rev 67975)
+++ 
Zope/branches/slinkp-1447-httpcache-fix-branch/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
 2006-05-05 02:22:12 UTC (rev 67976)
@@ -20,6 +20,8 @@
 
 from OFS.Cache import Cache, CacheManager
 from OFS.SimpleItem import SimpleItem
+import logging
+import socket
 import time
 from Globals import InitializeClass
 from Globals import DTMLFile
@@ -31,10 +33,15 @@
 from App.Common import rfc1123_date
 
 
+logger = logging.getLogger('Zope.AcceleratedHTTPCacheManager')
+
 class AcceleratedHTTPCache (Cache):
 # Note the need to take thread safety into account.
 # Also note that objects of this class are not persistent,
 # nor do they use acquisition.
+
+connection_factory = httplib.HTTPConnection
+
 def __init__(self):
 self.hit_counts = {}
 
@@ -44,14 +51,30 @@
 self.__dict__.update(kw)
 
 def ZCache_invalidate(self, ob):
-# Note that this only works for default views of objects.
+# Note that this only works for default views of objects at
+# their canonical path. If an object is viewed and cached at
+# any other path via acquisition or virtual hosting, that
+# cache entry cannot be purged because there is an infinite
+# number of such possible paths, and Squid does not support
+# any kind of fuzzy purging; we have to specify exactly the
+# URL to purge.  So we try to purge the known paths most
+# likely to turn up in practice: the physical path and the
+# current absolute_url_path.  Any of those can be
+# wrong in some circumstances, but it may be the best we can
+# do :-(
+# It would be nice if Squid's purge feature was better
+# documented.  (pot! kettle! black!)
+
 phys_path = ob.getPhysicalPath()
 if self.hit_counts.has_key(phys_path):
 del self.hit_counts[phys_path]
-ob_path = quote('/'.join(phys_path))
+purge_paths = (ob.absolute_url_path(), quote('/'.join(phys_path)))
+# Don't purge the same path twice.
+if purge_paths[0] == purge_paths[1]:
+purge_paths  = purge_paths[:1]
 results = []
 for url in self.notify_urls:
-if not url:
+if not url.strip():
 continue
 # Send the PURGE request to each HTTP accelerator.
 if url[:7].lower() == 'http://':
@@ -60,23 +83,37 @@
 u = 'http://' + url
 (scheme, host, path, params, query, fragment
  ) = urlparse.urlparse(u)
-if path[-1:] == '/':
-p = path[:-1] + ob_path
-else:
-p = path + ob_path
-h = httplib.HTTPConnection(host)
-h.request('PURGE', p)
-r = h.getresponse()
-results.append('%s %s' % (r.status, r.reason))
+if path.lower().startswith('/http://'):
+path = path.lstrip('/')
+for ob_path in purge_paths:
+p = path.rstrip('/') + ob_path
+h = self.connection_factory(host)
+logger.debug('PURGING host %s, path %s' % (host, p))
+# An exception on one purge should not prevent the others.
+try:
+h.request('PURGE', p)
+# This better not hang. I wish httplib gave us
+# control of timeouts.
+except socket.gaierror:
+msg = 'socket.gaierror: maybe the server ' + \
+  'at %s is down, or the cache manager ' + \
+  'is misconfigured?'
+logger.error(msg % url)
+continue
+r = h.getresponse()
+status = '%s %s' % (r.status, r.reason)
+results.append(status)
+logger.debug('purge response: %s' % status)
 return 'Server response(s): ' + ';'.join(results)
 
 def ZCache_get(self, ob, view_name, keywords, mtime_func, default):
 return 

[Zope-Checkins] SVN: Zope/branches/slinkp-1447-httpcache-fix-branch/doc/CHANGES.txt Noted fix for 1447 in CHANGES.txt.

2006-05-04 Thread Paul Winkler
Log message for revision 67977:
  Noted fix for 1447 in CHANGES.txt.
  

Changed:
  U   Zope/branches/slinkp-1447-httpcache-fix-branch/doc/CHANGES.txt

-=-
Modified: Zope/branches/slinkp-1447-httpcache-fix-branch/doc/CHANGES.txt
===
--- Zope/branches/slinkp-1447-httpcache-fix-branch/doc/CHANGES.txt  
2006-05-05 02:22:12 UTC (rev 67976)
+++ Zope/branches/slinkp-1447-httpcache-fix-branch/doc/CHANGES.txt  
2006-05-05 02:24:32 UTC (rev 67977)
@@ -243,6 +243,10 @@
 from the Zope 3 source tree (to get rid of redundant packages)
 
 Bugs Fixed
+
+  - Collector #1447: When editing content on a virtual-hosted zope,
+AcceleratedHTTPCacheManager now purges the correct URL.
+
   - When you add roles in manage_access, roles are now stripped of
 any leading or trailing spaces.
 

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


[Zope-Checkins] SVN: Zope/trunk/ Merged slinkp-1447-httpcache-fix-branch, -r 67975:67977.

2006-05-04 Thread Paul Winkler
Log message for revision 67978:
  Merged slinkp-1447-httpcache-fix-branch, -r 67975:67977.
  Fixes issue with AcceleratedHTTPCacheManager sending PURGE from a 
  virtual-hosted zope, and adds a bunch of related tests and comments.
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   
Zope/trunk/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
  U   
Zope/trunk/lib/python/Products/StandardCacheManagers/tests/test_AcceleratedHTTPCacheManager.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===
--- Zope/trunk/doc/CHANGES.txt  2006-05-05 02:24:32 UTC (rev 67977)
+++ Zope/trunk/doc/CHANGES.txt  2006-05-05 02:37:40 UTC (rev 67978)
@@ -243,6 +243,10 @@
 from the Zope 3 source tree (to get rid of redundant packages)
 
 Bugs Fixed
+
+  - Collector #1447: When editing content on a virtual-hosted zope,
+AcceleratedHTTPCacheManager now purges the correct URL.
+
   - When you add roles in manage_access, roles are now stripped of
 any leading or trailing spaces.
 

Modified: 
Zope/trunk/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
===
--- 
Zope/trunk/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
 2006-05-05 02:24:32 UTC (rev 67977)
+++ 
Zope/trunk/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
 2006-05-05 02:37:40 UTC (rev 67978)
@@ -20,6 +20,8 @@
 
 from OFS.Cache import Cache, CacheManager
 from OFS.SimpleItem import SimpleItem
+import logging
+import socket
 import time
 from Globals import InitializeClass
 from Globals import DTMLFile
@@ -31,10 +33,15 @@
 from App.Common import rfc1123_date
 
 
+logger = logging.getLogger('Zope.AcceleratedHTTPCacheManager')
+
 class AcceleratedHTTPCache (Cache):
 # Note the need to take thread safety into account.
 # Also note that objects of this class are not persistent,
 # nor do they use acquisition.
+
+connection_factory = httplib.HTTPConnection
+
 def __init__(self):
 self.hit_counts = {}
 
@@ -44,14 +51,30 @@
 self.__dict__.update(kw)
 
 def ZCache_invalidate(self, ob):
-# Note that this only works for default views of objects.
+# Note that this only works for default views of objects at
+# their canonical path. If an object is viewed and cached at
+# any other path via acquisition or virtual hosting, that
+# cache entry cannot be purged because there is an infinite
+# number of such possible paths, and Squid does not support
+# any kind of fuzzy purging; we have to specify exactly the
+# URL to purge.  So we try to purge the known paths most
+# likely to turn up in practice: the physical path and the
+# current absolute_url_path.  Any of those can be
+# wrong in some circumstances, but it may be the best we can
+# do :-(
+# It would be nice if Squid's purge feature was better
+# documented.  (pot! kettle! black!)
+
 phys_path = ob.getPhysicalPath()
 if self.hit_counts.has_key(phys_path):
 del self.hit_counts[phys_path]
-ob_path = quote('/'.join(phys_path))
+purge_paths = (ob.absolute_url_path(), quote('/'.join(phys_path)))
+# Don't purge the same path twice.
+if purge_paths[0] == purge_paths[1]:
+purge_paths  = purge_paths[:1]
 results = []
 for url in self.notify_urls:
-if not url:
+if not url.strip():
 continue
 # Send the PURGE request to each HTTP accelerator.
 if url[:7].lower() == 'http://':
@@ -60,23 +83,37 @@
 u = 'http://' + url
 (scheme, host, path, params, query, fragment
  ) = urlparse.urlparse(u)
-if path[-1:] == '/':
-p = path[:-1] + ob_path
-else:
-p = path + ob_path
-h = httplib.HTTPConnection(host)
-h.request('PURGE', p)
-r = h.getresponse()
-results.append('%s %s' % (r.status, r.reason))
+if path.lower().startswith('/http://'):
+path = path.lstrip('/')
+for ob_path in purge_paths:
+p = path.rstrip('/') + ob_path
+h = self.connection_factory(host)
+logger.debug('PURGING host %s, path %s' % (host, p))
+# An exception on one purge should not prevent the others.
+try:
+h.request('PURGE', p)
+# This better not hang. I wish httplib gave us
+# control of timeouts.
+except socket.gaierror:
+msg = 'socket.gaierror: maybe the server ' + \
+  'at %s is down, or the cache manager ' + \
+  'is 

[Zope-Checkins] SVN: Zope/branches/2.9/ Merged slinkp-1447-httpcache-fix-branch, -r 67975:67977.

2006-05-04 Thread Paul Winkler
Log message for revision 67979:
  Merged slinkp-1447-httpcache-fix-branch, -r 67975:67977.
  Fixes issue with AcceleratedHTTPCacheManager sending PURGE from a
  virtual-hosted zope, and adds a bunch of related tests and comments.
  

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt
  U   
Zope/branches/2.9/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
  U   
Zope/branches/2.9/lib/python/Products/StandardCacheManagers/tests/test_AcceleratedHTTPCacheManager.py

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===
--- Zope/branches/2.9/doc/CHANGES.txt   2006-05-05 02:37:40 UTC (rev 67978)
+++ Zope/branches/2.9/doc/CHANGES.txt   2006-05-05 03:01:21 UTC (rev 67979)
@@ -18,6 +18,9 @@
 
Bugs fixed
 
+  - Collector #1447: When editing content on a virtual-hosted zope,
+AcceleratedHTTPCacheManager now purges the correct URL.
+
   - Collector #2062: Fix manage_historyCopy, which was broken, and write
 tests for it.
 

Modified: 
Zope/branches/2.9/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
===
--- 
Zope/branches/2.9/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
  2006-05-05 02:37:40 UTC (rev 67978)
+++ 
Zope/branches/2.9/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
  2006-05-05 03:01:21 UTC (rev 67979)
@@ -20,6 +20,8 @@
 
 from OFS.Cache import Cache, CacheManager
 from OFS.SimpleItem import SimpleItem
+import logging
+import socket
 import time
 import Globals
 from Globals import DTMLFile
@@ -29,10 +31,15 @@
 from App.Common import rfc1123_date
 
 
+logger = logging.getLogger('Zope.AcceleratedHTTPCacheManager')
+
 class AcceleratedHTTPCache (Cache):
 # Note the need to take thread safety into account.
 # Also note that objects of this class are not persistent,
 # nor do they use acquisition.
+
+connection_factory = httplib.HTTPConnection
+
 def __init__(self):
 self.hit_counts = {}
 
@@ -42,14 +49,30 @@
 self.__dict__.update(kw)
 
 def ZCache_invalidate(self, ob):
-# Note that this only works for default views of objects.
+# Note that this only works for default views of objects at
+# their canonical path. If an object is viewed and cached at
+# any other path via acquisition or virtual hosting, that
+# cache entry cannot be purged because there is an infinite
+# number of such possible paths, and Squid does not support
+# any kind of fuzzy purging; we have to specify exactly the
+# URL to purge.  So we try to purge the known paths most
+# likely to turn up in practice: the physical path and the
+# current absolute_url_path.  Any of those can be
+# wrong in some circumstances, but it may be the best we can
+# do :-(
+# It would be nice if Squid's purge feature was better
+# documented.  (pot! kettle! black!)
+
 phys_path = ob.getPhysicalPath()
 if self.hit_counts.has_key(phys_path):
 del self.hit_counts[phys_path]
-ob_path = quote('/'.join(phys_path))
+purge_paths = (ob.absolute_url_path(), quote('/'.join(phys_path)))
+# Don't purge the same path twice.
+if purge_paths[0] == purge_paths[1]:
+purge_paths  = purge_paths[:1]
 results = []
 for url in self.notify_urls:
-if not url:
+if not url.strip():
 continue
 # Send the PURGE request to each HTTP accelerator.
 if url[:7].lower() == 'http://':
@@ -58,23 +81,37 @@
 u = 'http://' + url
 (scheme, host, path, params, query, fragment
  ) = urlparse.urlparse(u)
-if path[-1:] == '/':
-p = path[:-1] + ob_path
-else:
-p = path + ob_path
-h = httplib.HTTPConnection(host)
-h.request('PURGE', p)
-r = h.getresponse()
-results.append('%s %s' % (r.status, r.reason))
+if path.lower().startswith('/http://'):
+path = path.lstrip('/')
+for ob_path in purge_paths:
+p = path.rstrip('/') + ob_path
+h = self.connection_factory(host)
+logger.debug('PURGING host %s, path %s' % (host, p))
+# An exception on one purge should not prevent the others.
+try:
+h.request('PURGE', p)
+# This better not hang. I wish httplib gave us
+# control of timeouts.
+except socket.gaierror:
+msg = 'socket.gaierror: maybe the server ' + \
+  'at %s is down, or the cache manager ' + \
+  'is misconfigured?'
+logger.error(msg % 

[Zope-Checkins] SVN: Zope/branches/slinkp-httpcache-improvements-branch/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py added some TODO notes.

2006-05-04 Thread Paul Winkler
Log message for revision 67984:
  added some TODO notes.
  

Changed:
  U   
Zope/branches/slinkp-httpcache-improvements-branch/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py

-=-
Modified: 
Zope/branches/slinkp-httpcache-improvements-branch/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
===
--- 
Zope/branches/slinkp-httpcache-improvements-branch/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
 2006-05-05 04:17:02 UTC (rev 67983)
+++ 
Zope/branches/slinkp-httpcache-improvements-branch/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
 2006-05-05 04:46:22 UTC (rev 67984)
@@ -17,11 +17,15 @@
 
 XXX TODO: Consider adding features from this patch:
 
http://www.zope.org/Members/mtb/index_html/AcceleratedHTTPCacheManager-headers.diff/file_view
+ Related bug report: http://www.zope.org/Collectors/Zope/589
 
 XXX TODO: Add UI for strip_root_paths feature.
 
 XXX TODO: update help.stx.
 
+XXX TODO: a Purge All button would be handy. Check if Squid purges
+everything below a PURGE path, or only purges exactly that path.
+
 $Id$
 '''
 

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


[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Testing/tests/test_makerequest.py Belatedly removed test for the reverted 2057 bugfix. Whoops.

2006-04-11 Thread Paul Winkler
Log message for revision 66856:
  Belatedly removed test for the reverted 2057 bugfix. Whoops.
  
  

Changed:
  U   Zope/branches/2.9/lib/python/Testing/tests/test_makerequest.py

-=-
Modified: Zope/branches/2.9/lib/python/Testing/tests/test_makerequest.py
===
--- Zope/branches/2.9/lib/python/Testing/tests/test_makerequest.py  
2006-04-11 14:40:41 UTC (rev 66855)
+++ Zope/branches/2.9/lib/python/Testing/tests/test_makerequest.py  
2006-04-11 15:19:30 UTC (rev 66856)
@@ -32,13 +32,6 @@
 item = makerequest(item)
 self.failUnless(hasattr(item, 'REQUEST'))
 
-def test_dont_break_getPhysicalPath(self):
-# see http://www.zope.org/Collectors/Zope/2057
-item = SimpleItem()
-self.assertEqual(item.getPhysicalPath(), ('',))
-self.assertEqual(item.getPhysicalPath(),
- makerequest(item).getPhysicalPath())
-
 def test_stdout(self):
 # You can pass a stdout arg and it's used by the response.
 import cStringIO

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


[Zope-Checkins] SVN: Zope/trunk/lib/python/Testing/makerequest.py Fixed makerequest to not use os.environ by default.

2006-04-07 Thread Paul Winkler
Log message for revision 66651:
  Fixed makerequest to not use os.environ by default.
  

Changed:
  U   Zope/trunk/lib/python/Testing/makerequest.py

-=-
Modified: Zope/trunk/lib/python/Testing/makerequest.py
===
--- Zope/trunk/lib/python/Testing/makerequest.py2006-04-07 15:51:07 UTC 
(rev 66650)
+++ Zope/trunk/lib/python/Testing/makerequest.py2006-04-07 16:09:02 UTC 
(rev 66651)
@@ -19,12 +19,15 @@
 import makerequest
 app = makerequest.makerequest(Zope2.app())
 
-You can optionally pass stdout to be used by the response,
-and an environ mapping to be used in the request.
-Defaults are sys.stdout and os.environ.
+You can optionally pass stdout to be used by the response;
+default is sys.stdout.
 
+You can optionally pass an environ mapping to be used in the request.
+Default is a fresh dictionary. Passing os.environ is not recommended;
+tests should not pollute the real os.environ.
+
 If you don't want to start a zope app in your test, you can wrap other
-objects, but they must support acquisition and you should only wrap
+objects, but it must support acquisition and you should only wrap
 your root object.
 
 
@@ -38,10 +41,8 @@
 from ZPublisher.HTTPResponse import HTTPResponse
 from ZPublisher.BaseRequest import RequestContainer
 
-def makerequest(app, stdout=stdout, environ=None):
+def makerequest(app, stdout=stdout, environ={}):
 resp = HTTPResponse(stdout=stdout)
-if environ is None:
-environ = os.environ
 environ.setdefault('SERVER_NAME', 'foo')
 environ.setdefault('SERVER_PORT', '80')
 environ.setdefault('REQUEST_METHOD',  'GET')

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


[Zope-Checkins] SVN: Zope/trunk/ - Backed out workaround for 2057; on second thought,

2006-04-07 Thread Paul Winkler
Log message for revision 66656:
  - Backed out workaround for 2057; on second thought,
adding a getPhysicalPath() on a request just smells bad,
and it's not that hard to roll your own root object.
  
  - Fixed thinko with mutable default arg, duh.
  
  - Improved docstrings.
  
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Testing/makerequest.py
  U   Zope/trunk/lib/python/Testing/tests/test_makerequest.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===
--- Zope/trunk/doc/CHANGES.txt  2006-04-07 20:01:50 UTC (rev 66655)
+++ Zope/trunk/doc/CHANGES.txt  2006-04-08 01:40:12 UTC (rev 66656)
@@ -205,10 +205,6 @@
 
 Bugs Fixed
 
-  - Collector #2057: Allow Testing.makerequest to work with
-   any acquisition-supporting root object, not just Zope2.app.
-Formerly, if you did that, getPhysicalPath() was broken.
-
   - Collector #2051: Applied patch by Yoshinori Okuji to fix some
 XML export/import problems, including tests for that feature.
 

Modified: Zope/trunk/lib/python/Testing/makerequest.py
===
--- Zope/trunk/lib/python/Testing/makerequest.py2006-04-07 20:01:50 UTC 
(rev 66655)
+++ Zope/trunk/lib/python/Testing/makerequest.py2006-04-08 01:40:12 UTC 
(rev 66656)
@@ -14,23 +14,6 @@
 Facilitates unit tests which requires an acquirable REQUEST from
 ZODB objects
 
-Usage:
-
-import makerequest
-app = makerequest.makerequest(Zope2.app())
-
-You can optionally pass stdout to be used by the response;
-default is sys.stdout.
-
-You can optionally pass an environ mapping to be used in the request.
-Default is a fresh dictionary. Passing os.environ is not recommended;
-tests should not pollute the real os.environ.
-
-If you don't want to start a zope app in your test, you can wrap other
-objects, but it must support acquisition and you should only wrap
-your root object.
-
-
 $Id$
 
 
@@ -41,7 +24,34 @@
 from ZPublisher.HTTPResponse import HTTPResponse
 from ZPublisher.BaseRequest import RequestContainer
 
-def makerequest(app, stdout=stdout, environ={}):
+def makerequest(app, stdout=stdout, environ=None):
+
+Adds an HTTPRequest at app.REQUEST, and returns
+app.__of__(app.REQUEST). Useful for tests that need to acquire
+REQUEST.
+
+Usage:
+  import makerequest
+  app = makerequest.makerequest(app)
+
+You should only wrap the object used as 'root' in your tests.
+
+app is commonly a Zope2.app(), but that's not strictly necessary
+and frequently may be overkill; you can wrap other objects as long
+as they support acquisition and provide enough of the features of
+Zope2.app for your tests to run.  For example, if you want to call
+getPhysicalPath() on child objects, app must provide a
+non-recursive implementation of getPhysicalPath().
+
+*stdout* is an optional file-like object and is used by
+REQUEST.RESPONSE. The default is sys.stdout.
+
+*environ* is an optional mapping to be used in the request.
+Default is a fresh dictionary. Passing os.environ is not
+recommended; tests should not pollute the real os.environ.
+
+if environ is None:
+environ = {}
 resp = HTTPResponse(stdout=stdout)
 environ.setdefault('SERVER_NAME', 'foo')
 environ.setdefault('SERVER_PORT', '80')
@@ -56,14 +66,4 @@
 setDefaultSkin(req)
 
 requestcontainer = RequestContainer(REQUEST = req)
-# Workaround for collector 2057: ensure that we don't break
-# getPhysicalPath if app has that method.
-# We could instead fix Traversable.getPhysicalPath() to check for
-# existence of p.getPhysicalPath before calling it; but it's such
-# a commonly called method that I don't want to impact performance
-# for something that AFAICT only affects makerequest() in
-# practice.
-if getattr(app, 'getPhysicalPath', None) is not None:
-requestcontainer.getPhysicalPath = lambda: ()
-
 return app.__of__(requestcontainer)

Modified: Zope/trunk/lib/python/Testing/tests/test_makerequest.py
===
--- Zope/trunk/lib/python/Testing/tests/test_makerequest.py 2006-04-07 
20:01:50 UTC (rev 66655)
+++ Zope/trunk/lib/python/Testing/tests/test_makerequest.py 2006-04-08 
01:40:12 UTC (rev 66656)
@@ -33,9 +33,13 @@
 self.failUnless(hasattr(item, 'REQUEST'))
 
 def test_dont_break_getPhysicalPath(self):
-# see http://www.zope.org/Collectors/Zope/2057
-item = SimpleItem()
-self.assertEqual(item.getPhysicalPath(), ('',))
+# see http://www.zope.org/Collectors/Zope/2057.  If you want
+# to call getPhysicalPath() on the wrapped object, be sure
+# that it provides a non-recursive getPhysicalPath().
+class FakeRoot(SimpleItem):
+def getPhysicalPath(self):
+   

[Zope-Checkins] SVN: Zope/branches/2.9/configure Fixed acceptable versions, it wouldn't accept 2.4.2 properly.

2006-04-06 Thread Paul Winkler
Log message for revision 66597:
  Fixed acceptable versions, it wouldn't accept 2.4.2 properly.
  

Changed:
  U   Zope/branches/2.9/configure

-=-
Modified: Zope/branches/2.9/configure
===
--- Zope/branches/2.9/configure 2006-04-06 17:12:03 UTC (rev 66596)
+++ Zope/branches/2.9/configure 2006-04-06 17:46:52 UTC (rev 66597)
@@ -18,7 +18,7 @@
 # sys.version) below in best to worst order, not including the
 # target version.  Up to six acceptable python versions are allowed.
 # Do not include the target version number in this list!
-ACCEPTABLE=2.4.1 2.4.2.
+ACCEPTABLE=2.4.1 2.4.2
 
 # provide the executable names for all the acceptable versions
 # (and the target version) below

___
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/Sessions/tests/testBrowserIdManager.py Tests should not pollute os.environ when a dict will do just fine;

2006-04-06 Thread Paul Winkler
Log message for revision 66605:
  Tests should not pollute os.environ when a dict will do just fine;
  this caused failures in testVirtualHostMonster when Testing/makerequest
  was modified. 
  
  

Changed:
  U   
Zope/branches/2.9/lib/python/Products/Sessions/tests/testBrowserIdManager.py

-=-
Modified: 
Zope/branches/2.9/lib/python/Products/Sessions/tests/testBrowserIdManager.py
===
--- 
Zope/branches/2.9/lib/python/Products/Sessions/tests/testBrowserIdManager.py
2006-04-06 18:56:13 UTC (rev 66604)
+++ 
Zope/branches/2.9/lib/python/Products/Sessions/tests/testBrowserIdManager.py
2006-04-06 19:03:04 UTC (rev 66605)
@@ -27,7 +27,6 @@
 from ZPublisher.HTTPResponse import HTTPResponse
 from ZPublisher.BeforeTraverse import queryBeforeTraverse
 from sys import stdin
-from os import environ
 from OFS.Application import Application
 
 class TestBrowserIdManager(TestCase):
@@ -38,6 +37,7 @@
 self.app._setObject('browser_id_manager', mgr)
 self.m = self.app.browser_id_manager
 resp = HTTPResponse()
+environ = {}
 environ['SERVER_NAME']='fred'
 environ['SERVER_PORT']='80'
 self.req = HTTPRequest(stdin, environ, resp)
@@ -238,6 +238,7 @@
 bid = '43295340A0bpcu4nkCI'
 name = '_ZopeId'
 resp = HTTPResponse()
+environ = {}
 environ['SERVER_NAME']='fred'
 environ['SERVER_PORT']='80'
 self.req = HTTPRequest(stdin, environ, resp)

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


[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/Sessions/tests/testBrowserIdManager.py Merged environment pollution fix from 2.9 branch.

2006-04-06 Thread Paul Winkler
Log message for revision 66609:
  Merged environment pollution fix from 2.9 branch.
  

Changed:
  U   Zope/trunk/lib/python/Products/Sessions/tests/testBrowserIdManager.py

-=-
Modified: Zope/trunk/lib/python/Products/Sessions/tests/testBrowserIdManager.py
===
--- Zope/trunk/lib/python/Products/Sessions/tests/testBrowserIdManager.py   
2006-04-06 19:11:09 UTC (rev 66608)
+++ Zope/trunk/lib/python/Products/Sessions/tests/testBrowserIdManager.py   
2006-04-06 19:11:54 UTC (rev 66609)
@@ -27,7 +27,6 @@
 from ZPublisher.HTTPResponse import HTTPResponse
 from ZPublisher.BeforeTraverse import queryBeforeTraverse
 from sys import stdin
-from os import environ
 from OFS.Application import Application
 
 class TestBrowserIdManager(TestCase):
@@ -38,6 +37,7 @@
 self.app._setObject('browser_id_manager', mgr)
 self.m = self.app.browser_id_manager
 resp = HTTPResponse()
+environ = {}
 environ['SERVER_NAME']='fred'
 environ['SERVER_PORT']='80'
 self.req = HTTPRequest(stdin, environ, resp)
@@ -238,6 +238,7 @@
 bid = '43295340A0bpcu4nkCI'
 name = '_ZopeId'
 resp = HTTPResponse()
+environ = {}
 environ['SERVER_NAME']='fred'
 environ['SERVER_PORT']='80'
 self.req = HTTPRequest(stdin, environ, resp)

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


[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Testing/ Reverting refactoring of ZopeTestCase.utils.makerequest,

2006-04-06 Thread Paul Winkler
Log message for revision 66621:
  Reverting refactoring of ZopeTestCase.utils.makerequest,
  and the related addition of an environ argument to
  Testing.makerequest.  This was not a bugfix, thus inappropriate
  for the stable branch.  Apologies.
  

Changed:
  U   Zope/branches/2.9/lib/python/Testing/ZopeTestCase/utils.py
  U   Zope/branches/2.9/lib/python/Testing/makerequest.py
  U   Zope/branches/2.9/lib/python/Testing/tests/test_makerequest.py

-=-
Modified: Zope/branches/2.9/lib/python/Testing/ZopeTestCase/utils.py
===
--- Zope/branches/2.9/lib/python/Testing/ZopeTestCase/utils.py  2006-04-06 
21:23:23 UTC (rev 66620)
+++ Zope/branches/2.9/lib/python/Testing/ZopeTestCase/utils.py  2006-04-06 
21:30:58 UTC (rev 66621)
@@ -127,14 +127,26 @@
 
 def makerequest(app, stdout=sys.stdout):
 '''Wraps the app into a fresh REQUEST.'''
-from Testing.makerequest import makerequest as _makerequest
+from ZPublisher.BaseRequest import RequestContainer
+from ZPublisher.Request import Request
+from ZPublisher.Response import Response
+response = Response(stdout=stdout)
 environ = {}
 environ['SERVER_NAME'] = _Z2HOST or 'nohost'
 environ['SERVER_PORT'] = '%d' % (_Z2PORT or 80)
 environ['REQUEST_METHOD'] = 'GET'
-app = _makerequest(app, stdout=stdout, environ=environ)
-return app
+request = Request(sys.stdin, environ, response)
+request._steps = ['noobject'] # Fake a published object
+request['ACTUAL_URL'] = request.get('URL') # Zope 2.7.4
 
+# set Zope3-style default skin so that the request is usable for
+# Zope3-style view look-ups
+from zope.app.publication.browser import setDefaultSkin
+setDefaultSkin(request)
+
+return app.__of__(RequestContainer(REQUEST=request))
+
+
 def appcall(function, *args, **kw):
 '''Calls a function passing 'app' as first argument.'''
 from base import app, close

Modified: Zope/branches/2.9/lib/python/Testing/makerequest.py
===
--- Zope/branches/2.9/lib/python/Testing/makerequest.py 2006-04-06 21:23:23 UTC 
(rev 66620)
+++ Zope/branches/2.9/lib/python/Testing/makerequest.py 2006-04-06 21:30:58 UTC 
(rev 66621)
@@ -38,13 +38,12 @@
 from ZPublisher.HTTPResponse import HTTPResponse
 from ZPublisher.BaseRequest import RequestContainer
 
-def makerequest(app, stdout=stdout, environ=None):
+def makerequest(app, stdout=stdout):
 resp = HTTPResponse(stdout=stdout)
-if environ is None:
-environ = os.environ
-environ.setdefault('SERVER_NAME', 'foo')
-environ.setdefault('SERVER_PORT', '80')
-environ.setdefault('REQUEST_METHOD',  'GET')
+environ = os.environ
+environ['SERVER_NAME'] = 'foo'
+environ['SERVER_PORT'] = '80'
+environ['REQUEST_METHOD'] =  'GET'
 req = HTTPRequest(stdin, environ, resp)
 req._steps = ['noobject']  # Fake a published object.
 req['ACTUAL_URL'] = req.get('URL') # Zope 2.7.4

Modified: Zope/branches/2.9/lib/python/Testing/tests/test_makerequest.py
===
--- Zope/branches/2.9/lib/python/Testing/tests/test_makerequest.py  
2006-04-06 21:23:23 UTC (rev 66620)
+++ Zope/branches/2.9/lib/python/Testing/tests/test_makerequest.py  
2006-04-06 21:30:58 UTC (rev 66621)
@@ -50,11 +50,6 @@
 self.failUnless(written.startswith('Status: 200 OK\n'))
 self.failUnless(written.endswith('\naaa'))
 
-def test_environ(self):
-# You can pass an environ argument to use in the request.
-environ = {'foofoo': 'barbar'}
-item = makerequest(SimpleItem(), environ=environ)
-self.assertEqual(item.REQUEST.environ['foofoo'], 'barbar')
 
 def test_suite():
 suite = unittest.TestSuite()

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


[Zope-Checkins] SVN: Zope/trunk/ Fixed collector 2057: Testing.makequest broke getPhysicalPath()

2006-04-05 Thread Paul Winkler
Log message for revision 66581:
  Fixed collector 2057: Testing.makequest broke getPhysicalPath()
  when used on anything other than an app object.
  Also added an 'environ' argument if you want to use something
  other than os.environ, and added a couple trivial tweaks from 
  ZopeTestCase.makereqeust.
  Added unit tests for this stuff.
  
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Testing/makerequest.py
  A   Zope/trunk/lib/python/Testing/tests/
  A   Zope/trunk/lib/python/Testing/tests/__init__.py
  A   Zope/trunk/lib/python/Testing/tests/test_makerequest.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===
--- Zope/trunk/doc/CHANGES.txt  2006-04-05 20:04:59 UTC (rev 66580)
+++ Zope/trunk/doc/CHANGES.txt  2006-04-05 20:51:21 UTC (rev 66581)
@@ -46,6 +46,9 @@
 
 Features added
 
+  - Testing.makerequest: Added an 'environ' argument so
+clients can use mappings other than os.environ.
+
   - Updated to Docutils 0.4.0 
 
   - reStructuredText: The default value for the 'stylesheet'
@@ -202,6 +205,10 @@
 
 Bugs Fixed
 
+  - Collector #2057: Allow Testing.makerequest to work with
+   any acquisition-supporting root object, not just Zope2.app.
+Formerly, if you did that, getPhysicalPath() was broken.
+
   - Collector #2051: Applied patch by Yoshinori Okuji to fix some
 XML export/import problems, including tests for that feature.
 

Modified: Zope/trunk/lib/python/Testing/makerequest.py
===
--- Zope/trunk/lib/python/Testing/makerequest.py2006-04-05 20:04:59 UTC 
(rev 66580)
+++ Zope/trunk/lib/python/Testing/makerequest.py2006-04-05 20:51:21 UTC 
(rev 66581)
@@ -19,27 +19,50 @@
 import makerequest
 app = makerequest.makerequest(Zope2.app())
 
+You can optionally pass stdout to be used by the response,
+and an environ mapping to be used in the request.
+Defaults are sys.stdout and os.environ.
+
+If you don't want to start a zope app in your test, you can wrap other
+objects, but they must support acquisition and you should only wrap
+your root object.
+
+
 $Id$
 
 
 
 import os
-from os import environ
 from sys import stdin, stdout
 from ZPublisher.HTTPRequest import HTTPRequest
 from ZPublisher.HTTPResponse import HTTPResponse
 from ZPublisher.BaseRequest import RequestContainer
 
-def makerequest(app, stdout=stdout):
+def makerequest(app, stdout=stdout, environ=None):
 resp = HTTPResponse(stdout=stdout)
-environ['SERVER_NAME']='foo'
-environ['SERVER_PORT']='80'
-environ['REQUEST_METHOD'] = 'GET'
+if environ is None:
+environ = os.environ
+environ.setdefault('SERVER_NAME', 'foo')
+environ.setdefault('SERVER_PORT', '80')
+environ.setdefault('REQUEST_METHOD',  'GET')
 req = HTTPRequest(stdin, environ, resp)
-
+req._steps = ['noobject']  # Fake a published object.
+req['ACTUAL_URL'] = req.get('URL') # Zope 2.7.4
+
 # set Zope3-style default skin so that the request is usable for
-# Zope3-style view look-ups
+# Zope3-style view look-ups.
 from zope.app.publication.browser import setDefaultSkin
 setDefaultSkin(req)
 
-return app.__of__(RequestContainer(REQUEST = req))
+requestcontainer = RequestContainer(REQUEST = req)
+# Workaround for collector 2057: ensure that we don't break
+# getPhysicalPath if app has that method.
+# We could instead fix Traversable.getPhysicalPath() to check for
+# existence of p.getPhysicalPath before calling it; but it's such
+# a commonly called method that I don't want to impact performance
+# for something that AFAICT only affects makerequest() in
+# practice.
+if getattr(app, 'getPhysicalPath', None) is not None:
+requestcontainer.getPhysicalPath = lambda: ()
+
+return app.__of__(requestcontainer)

Added: Zope/trunk/lib/python/Testing/tests/__init__.py
===
--- Zope/trunk/lib/python/Testing/tests/__init__.py 2006-04-05 20:04:59 UTC 
(rev 66580)
+++ Zope/trunk/lib/python/Testing/tests/__init__.py 2006-04-05 20:51:21 UTC 
(rev 66581)
@@ -0,0 +1 @@
+#


Property changes on: Zope/trunk/lib/python/Testing/tests/__init__.py
___
Name: svn:keywords
   + Author Date Revision

Added: Zope/trunk/lib/python/Testing/tests/test_makerequest.py
===
--- Zope/trunk/lib/python/Testing/tests/test_makerequest.py 2006-04-05 
20:04:59 UTC (rev 66580)
+++ Zope/trunk/lib/python/Testing/tests/test_makerequest.py 2006-04-05 
20:51:21 UTC (rev 66581)
@@ -0,0 +1,65 @@
+##
+#
+# Copyright (c) 2006 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is 

[Zope-Checkins] SVN: Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py Removed duplicate code from ZopeTestCase.utils.makerequest;

2006-04-05 Thread Paul Winkler
Log message for revision 66582:
  Removed duplicate code from ZopeTestCase.utils.makerequest;
  it now wraps Testing.makerequest.makerequest().
  
  

Changed:
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py

-=-
Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py
===
--- Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py 2006-04-05 20:51:21 UTC 
(rev 66581)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/utils.py 2006-04-05 20:52:39 UTC 
(rev 66582)
@@ -127,26 +127,14 @@
 
 def makerequest(app, stdout=sys.stdout):
 '''Wraps the app into a fresh REQUEST.'''
-from ZPublisher.BaseRequest import RequestContainer
-from ZPublisher.Request import Request
-from ZPublisher.Response import Response
-response = Response(stdout=stdout)
+from Testing.makerequest import makerequest as _makerequest
 environ = {}
 environ['SERVER_NAME'] = _Z2HOST or 'nohost'
 environ['SERVER_PORT'] = '%d' % (_Z2PORT or 80)
 environ['REQUEST_METHOD'] = 'GET'
-request = Request(sys.stdin, environ, response)
-request._steps = ['noobject'] # Fake a published object
-request['ACTUAL_URL'] = request.get('URL') # Zope 2.7.4
+app = _makerequest(app, stdout=stdout, environ=environ)
+return app
 
-# set Zope3-style default skin so that the request is usable for
-# Zope3-style view look-ups
-from zope.app.publication.browser import setDefaultSkin
-setDefaultSkin(request)
-
-return app.__of__(RequestContainer(REQUEST=request))
-
-
 def appcall(function, *args, **kw):
 '''Calls a function passing 'app' as first argument.'''
 from base import app, close

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


[Zope-Checkins] SVN: Zope/branches/2.9/ Merged makerequest fixes from trunk (collector 2057).

2006-04-05 Thread Paul Winkler
Log message for revision 66583:
  Merged makerequest fixes from trunk (collector 2057).
  

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt
  U   Zope/branches/2.9/lib/python/Testing/ZopeTestCase/utils.py
  U   Zope/branches/2.9/lib/python/Testing/makerequest.py
  A   Zope/branches/2.9/lib/python/Testing/tests/

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===
--- Zope/branches/2.9/doc/CHANGES.txt   2006-04-05 20:52:39 UTC (rev 66582)
+++ Zope/branches/2.9/doc/CHANGES.txt   2006-04-05 21:13:42 UTC (rev 66583)
@@ -14,6 +14,14 @@
  to the rules for such a type laid out in the Python docs:
  http://docs.python.org/api/supporting-cycle-detection.html
 
+  Zope 2.9.3 (UNRELEASED)
+
+   Bugs fixed
+
+  - Collector #2057: Allow Testing.makerequest to work with
+any acquisition-supporting root object, not just Zope2.app.
+Formerly, if you did that, getPhysicalPath() was broken.
+
   Zope 2.9.2 (2006/03/27)
 
 Bugs fixed

Modified: Zope/branches/2.9/lib/python/Testing/ZopeTestCase/utils.py
===
--- Zope/branches/2.9/lib/python/Testing/ZopeTestCase/utils.py  2006-04-05 
20:52:39 UTC (rev 66582)
+++ Zope/branches/2.9/lib/python/Testing/ZopeTestCase/utils.py  2006-04-05 
21:13:42 UTC (rev 66583)
@@ -127,26 +127,14 @@
 
 def makerequest(app, stdout=sys.stdout):
 '''Wraps the app into a fresh REQUEST.'''
-from ZPublisher.BaseRequest import RequestContainer
-from ZPublisher.Request import Request
-from ZPublisher.Response import Response
-response = Response(stdout=stdout)
+from Testing.makerequest import makerequest as _makerequest
 environ = {}
 environ['SERVER_NAME'] = _Z2HOST or 'nohost'
 environ['SERVER_PORT'] = '%d' % (_Z2PORT or 80)
 environ['REQUEST_METHOD'] = 'GET'
-request = Request(sys.stdin, environ, response)
-request._steps = ['noobject'] # Fake a published object
-request['ACTUAL_URL'] = request.get('URL') # Zope 2.7.4
+app = _makerequest(app, stdout=stdout, environ=environ)
+return app
 
-# set Zope3-style default skin so that the request is usable for
-# Zope3-style view look-ups
-from zope.app.publication.browser import setDefaultSkin
-setDefaultSkin(request)
-
-return app.__of__(RequestContainer(REQUEST=request))
-
-
 def appcall(function, *args, **kw):
 '''Calls a function passing 'app' as first argument.'''
 from base import app, close

Modified: Zope/branches/2.9/lib/python/Testing/makerequest.py
===
--- Zope/branches/2.9/lib/python/Testing/makerequest.py 2006-04-05 20:52:39 UTC 
(rev 66582)
+++ Zope/branches/2.9/lib/python/Testing/makerequest.py 2006-04-05 21:13:42 UTC 
(rev 66583)
@@ -19,27 +19,50 @@
 import makerequest
 app = makerequest.makerequest(Zope2.app())
 
+You can optionally pass stdout to be used by the response,
+and an environ mapping to be used in the request.
+Defaults are sys.stdout and os.environ.
+
+If you don't want to start a zope app in your test, you can wrap other
+objects, but they must support acquisition and you should only wrap
+your root object.
+
+
 $Id$
 
 
 
 import os
-from os import environ
 from sys import stdin, stdout
 from ZPublisher.HTTPRequest import HTTPRequest
 from ZPublisher.HTTPResponse import HTTPResponse
 from ZPublisher.BaseRequest import RequestContainer
 
-def makerequest(app, stdout=stdout):
+def makerequest(app, stdout=stdout, environ=None):
 resp = HTTPResponse(stdout=stdout)
-environ['SERVER_NAME']='foo'
-environ['SERVER_PORT']='80'
-environ['REQUEST_METHOD'] = 'GET'
+if environ is None:
+environ = os.environ
+environ.setdefault('SERVER_NAME', 'foo')
+environ.setdefault('SERVER_PORT', '80')
+environ.setdefault('REQUEST_METHOD',  'GET')
 req = HTTPRequest(stdin, environ, resp)
-
+req._steps = ['noobject']  # Fake a published object.
+req['ACTUAL_URL'] = req.get('URL') # Zope 2.7.4
+
 # set Zope3-style default skin so that the request is usable for
-# Zope3-style view look-ups
+# Zope3-style view look-ups.
 from zope.app.publication.browser import setDefaultSkin
 setDefaultSkin(req)
 
-return app.__of__(RequestContainer(REQUEST = req))
+requestcontainer = RequestContainer(REQUEST = req)
+# Workaround for collector 2057: ensure that we don't break
+# getPhysicalPath if app has that method.
+# We could instead fix Traversable.getPhysicalPath() to check for
+# existence of p.getPhysicalPath before calling it; but it's such
+# a commonly called method that I don't want to impact performance
+# for something that AFAICT only affects makerequest() in
+# practice.
+if getattr(app, 'getPhysicalPath', None) is not None:
+requestcontainer.getPhysicalPath = lambda: ()
+
+return app.__of__(requestcontainer)

Copied: 

[Zope-Checkins] SVN: Zope/trunk/doc/INSTALL.txt Trivial typo, WEBSERVER.txt was misspelled.

2005-12-12 Thread Paul Winkler
Log message for revision 40731:
  Trivial typo, WEBSERVER.txt was misspelled.
  

Changed:
  U   Zope/trunk/doc/INSTALL.txt

-=-
Modified: Zope/trunk/doc/INSTALL.txt
===
--- Zope/trunk/doc/INSTALL.txt  2005-12-12 15:56:57 UTC (rev 40730)
+++ Zope/trunk/doc/INSTALL.txt  2005-12-12 16:13:53 UTC (rev 40731)
@@ -181,7 +181,7 @@
 
   Zope doesn't require any existing webserver to run, but you can
   integrate it with other webservers as necessary.  See the
-  WEBSERVERS.txt file for more information about configuring Zope with
+  WEBSERVER.txt file for more information about configuring Zope with
   an existing web server.  There is also information about integrating
   Zope with existing webservers on the Zope.org website.
 

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


[Zope-Checkins] SVN: Zope/branches/2.9/doc/ Trivial doc fixes from trunk.

2005-12-12 Thread Paul Winkler
Log message for revision 40736:
  Trivial doc fixes from trunk.
  

Changed:
  U   Zope/branches/2.9/doc/FAQ.txt
  U   Zope/branches/2.9/doc/INSTALL.txt

-=-
Modified: Zope/branches/2.9/doc/FAQ.txt
===
--- Zope/branches/2.9/doc/FAQ.txt   2005-12-12 16:31:56 UTC (rev 40735)
+++ Zope/branches/2.9/doc/FAQ.txt   2005-12-12 16:36:13 UTC (rev 40736)
@@ -277,15 +277,11 @@
browser.  Clear your cache and view the HTML source again.
 
 
-2. I'm using Python 2.4 and I'm having a problem ...
+2. I'm using Python 2.x and I'm having a problem ...
 
-   As of the release of Zope 2.8, Python 2.4 has not been approved for 
-   use with any version of Zope yet.  Please use Python 2.3. 
-
The correct version of Python should always be automatically detected
and used when you configure and install Zope. In general, you 
should let the configure script do its job and don't try to 
force an unsupported version of Python!
 
 
-

Modified: Zope/branches/2.9/doc/INSTALL.txt
===
--- Zope/branches/2.9/doc/INSTALL.txt   2005-12-12 16:31:56 UTC (rev 40735)
+++ Zope/branches/2.9/doc/INSTALL.txt   2005-12-12 16:36:13 UTC (rev 40736)
@@ -181,7 +181,7 @@
 
   Zope doesn't require any existing webserver to run, but you can
   integrate it with other webservers as necessary.  See the
-  WEBSERVERS.txt file for more information about configuring Zope with
+  WEBSERVER.txt file for more information about configuring Zope with
   an existing web server.  There is also information about integrating
   Zope with existing webservers on the Zope.org website.
 

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


[Zope-Checkins] SVN: Zope/branches/2.9/ OFS ObjectManager: Fixed list_imports() to tolerate missing

2005-12-12 Thread Paul Winkler
Log message for revision 40756:
  OFS ObjectManager: Fixed list_imports() to tolerate missing
  import directories. (Merged from trunk.)
  

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt
  U   Zope/branches/2.9/lib/python/OFS/ObjectManager.py
  U   Zope/branches/2.9/lib/python/OFS/tests/testObjectManager.py

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===
--- Zope/branches/2.9/doc/CHANGES.txt   2005-12-12 21:05:33 UTC (rev 40755)
+++ Zope/branches/2.9/doc/CHANGES.txt   2005-12-12 21:07:07 UTC (rev 40756)
@@ -27,6 +27,9 @@
 
 Bugs fixed
 
+ - OFS ObjectManager: Fixed list_imports() to tolerate missing
+   import directories.
+
  - Collector #1965: 'get_transaction' missing from builtins without
sufficient deprecation notice (ZODB 3.6 properly removed it, but
Zope needs to keep it for another release).

Modified: Zope/branches/2.9/lib/python/OFS/ObjectManager.py
===
--- Zope/branches/2.9/lib/python/OFS/ObjectManager.py   2005-12-12 21:05:33 UTC 
(rev 40755)
+++ Zope/branches/2.9/lib/python/OFS/ObjectManager.py   2005-12-12 21:07:07 UTC 
(rev 40756)
@@ -619,6 +619,8 @@
 paths.append(cfg.instancehome)
 for impath in paths:
 directory = os.path.join(impath, 'import')
+if not os.path.isdir(directory):
+continue
 listing += [f for f in os.listdir(directory)
 if f.endswith('.zexp') or f.endswith('.xml')]
 return listing

Modified: Zope/branches/2.9/lib/python/OFS/tests/testObjectManager.py
===
--- Zope/branches/2.9/lib/python/OFS/tests/testObjectManager.py 2005-12-12 
21:05:33 UTC (rev 40755)
+++ Zope/branches/2.9/lib/python/OFS/tests/testObjectManager.py 2005-12-12 
21:07:07 UTC (rev 40756)
@@ -108,7 +108,6 @@
 self.assertEqual( si.__ac_local_roles__, None )
 
 def test_setObject_set_owner_with_emergency_user( self ):
-
 om = self._makeOne()
 
 newSecurityManager( None, emergency_user )
@@ -380,6 +379,16 @@
 self.assertRaises(BadRequest, om._setObject, 'REQUEST', si)
 self.assertRaises(BadRequest, om._setObject, '/', si)
 
+def test_list_imports(self):
+om = self._makeOne()
+# This must work whether we've done make instance or not.
+# So list_imports() may return an empty list, or whatever's
+# in skel/import. Tolerate both cases.
+self.failUnless(isinstance(om.list_imports(), list))
+for filename in om.list_imports():
+self.failUnless(filename.endswith('.zexp') or
+filename.endswith('.xml'))
+
 def test_suite():
 suite = unittest.TestSuite()
 suite.addTest( unittest.makeSuite( ObjectManagerTests ) )

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


[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PythonScripts/module_access_examples.py Removed some unused imports.

2005-12-02 Thread Paul Winkler
Log message for revision 40494:
  Removed some unused imports. 
  

Changed:
  U   Zope/trunk/lib/python/Products/PythonScripts/module_access_examples.py

-=-
Modified: Zope/trunk/lib/python/Products/PythonScripts/module_access_examples.py
===
--- Zope/trunk/lib/python/Products/PythonScripts/module_access_examples.py  
2005-12-02 17:30:34 UTC (rev 40493)
+++ Zope/trunk/lib/python/Products/PythonScripts/module_access_examples.py  
2005-12-02 17:42:58 UTC (rev 40494)
@@ -33,8 +33,7 @@
 '''
 
 from AccessControl import allow_module, allow_class, allow_type
-from AccessControl import ModuleSecurityInfo, ClassSecurityInfo
-from Globals import InitializeClass
+from AccessControl import ModuleSecurityInfo
 
 
 # These modules are pretty safe

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


[Zope-Checkins] SVN: Zope/branches/slinkp-collector_596/ Cleaned up an old branch.

2005-11-13 Thread Paul Winkler
Log message for revision 40067:
  Cleaned up an old branch.
  

Changed:
  D   Zope/branches/slinkp-collector_596/

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


[Zope-Checkins] SVN: Zope/branches/slinkp_1726_zopeundo/ Cleaned out old branch.

2005-11-13 Thread Paul Winkler
Log message for revision 40069:
  Cleaned out old branch.
  

Changed:
  D   Zope/branches/slinkp_1726_zopeundo/

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


[Zope-Checkins] SVN: Zope/branches/slinkp-configure_changes/configure - No longer try to execute directories.

2005-11-13 Thread Paul Winkler
Log message for revision 40075:
  - No longer try to execute directories.
  

Changed:
  U   Zope/branches/slinkp-configure_changes/configure

-=-
Modified: Zope/branches/slinkp-configure_changes/configure
===
--- Zope/branches/slinkp-configure_changes/configure2005-11-12 18:29:16 UTC 
(rev 40074)
+++ Zope/branches/slinkp-configure_changes/configure2005-11-12 18:43:46 UTC 
(rev 40075)
@@ -77,7 +77,7 @@
 IFS=$OLDIFS
 for EXECUTABLE in $EXENAMES; do
 FULL=$DIR/$EXECUTABLE
-if [ -x $FULL ]; then
+if [ -x $FULL -a ! -d $FULL ]; then
 CMD=import string,sys;a=string.split(sys.version)[0]
# Strip trailing + from version number
CMD=$CMD;a=(a[-1]=='+')and(a[:-1])or(a);print a
@@ -86,7 +86,6 @@
i=0;
 for P in $PREFERRED; do
i=`expr $i + 1`
-   echo XXX I: $i
for SLOT in $PREF_FOUNDLIST; do
if [ $SLOT -eq $i ]; then
 # slot i already populated.  
@@ -110,7 +109,6 @@
 i=0;
 for ACC in $ACCEPTABLE; do
 i=`expr $i + 1`
-   echo I XXX $i
for SLOT in $FOUNDLIST; do
 if [ $SLOT -eq $i ]; then
 # slot i already populated.  This means we've

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