[Zope-Checkins] SVN: Zope/trunk/ - LP #143564: Request.resolve_url did not correctly re-raise

2010-07-14 Thread Jens Vagelpohl
Log message for revision 114737:
  - LP #143564: Request.resolve_url did not correctly re-raise
exceptions encountered during path traversal.
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/ZPublisher/HTTPRequest.py
  U   Zope/trunk/src/ZPublisher/tests/testHTTPRequest.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===
--- Zope/trunk/doc/CHANGES.rst  2010-07-14 11:35:57 UTC (rev 114736)
+++ Zope/trunk/doc/CHANGES.rst  2010-07-14 11:40:36 UTC (rev 114737)
@@ -11,7 +11,10 @@
 Bugs Fixed
 ++
 
+- LP #143564: Request.resolve_url did not correctly re-raise
+  exceptions encountered during path traversal.
 
+
 Restructuring
 +
 

Modified: Zope/trunk/src/ZPublisher/HTTPRequest.py
===
--- Zope/trunk/src/ZPublisher/HTTPRequest.py2010-07-14 11:35:57 UTC (rev 
114736)
+++ Zope/trunk/src/ZPublisher/HTTPRequest.py2010-07-14 11:40:36 UTC (rev 
114737)
@@ -1178,7 +1178,7 @@
 rsp.exception()
 if object is None:
 req.clear()
-raise rsp.errmsg, sys.exc_info()[1]
+raise sys.exc_info()[0], rsp.errmsg
 
 # The traversal machinery may return a default object
 # like an index_html document. This is not appropriate

Modified: Zope/trunk/src/ZPublisher/tests/testHTTPRequest.py
===
--- Zope/trunk/src/ZPublisher/tests/testHTTPRequest.py  2010-07-14 11:35:57 UTC 
(rev 114736)
+++ Zope/trunk/src/ZPublisher/tests/testHTTPRequest.py  2010-07-14 11:40:36 UTC 
(rev 114737)
@@ -19,6 +19,7 @@
 
 def _makeOne(self, stdin=None, environ=None, response=None, clean=1):
 from StringIO import StringIO
+from ZPublisher import NotFound
 if stdin is None:
 stdin = StringIO()
 
@@ -37,7 +38,15 @@
 if response is None:
 class _FauxResponse(object):
 _auth = None
+debug_mode = False
+errmsg = 'OK'
 
+def notFoundError(self, message):
+raise NotFound, message
+
+def exception(self, *args, **kw):
+pass
+
 response = _FauxResponse()
 
 return self._getTargetClass()(stdin, environ, response, clean)
@@ -1002,6 +1011,16 @@
 self.failIf(len(events),
 HTTPRequest.resolve_url should not emit events)
 
+def test_resolve_url_errorhandling(self):
+# Check that resolve_url really raises the same error
+# it received from ZPublisher.BaseRequest.traverse
+from zExceptions import NotFound
+request = self._makeOne()
+request['PARENTS'] = [object()]
+self.assertRaises( NotFound
+ , request.resolve_url
+ , request.script + '/does_not_exist'
+ )
 
 def test_parses_json_cookies(self):
 # https://bugs.launchpad.net/zope2/+bug/563229

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


[Zope-Checkins] SVN: Zope/branches/2.12/ - LP #143722: Added missing permission to ObjectManager.manage_hasId,

2010-07-14 Thread Jens Vagelpohl
Log message for revision 114738:
  - LP #143722: Added missing permission to ObjectManager.manage_hasId,
which prevented renaming files and folders via FTP.
  

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/OFS/ObjectManager.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===
--- Zope/branches/2.12/doc/CHANGES.rst  2010-07-14 11:40:36 UTC (rev 114737)
+++ Zope/branches/2.12/doc/CHANGES.rst  2010-07-14 12:08:07 UTC (rev 114738)
@@ -11,6 +11,9 @@
 Bugs Fixed
 ++
 
+- LP #143722: Added missing permission to ObjectManager.manage_hasId,
+  which prevented renaming files and folders via FTP.
+
 - LP #143564: Request.resolve_url did not correctly re-raise 
   exceptions encountered during path traversal.
 

Modified: Zope/branches/2.12/src/OFS/ObjectManager.py
===
--- Zope/branches/2.12/src/OFS/ObjectManager.py 2010-07-14 11:40:36 UTC (rev 
114737)
+++ Zope/branches/2.12/src/OFS/ObjectManager.py 2010-07-14 12:08:07 UTC (rev 
114738)
@@ -733,6 +733,7 @@
 out=out+((k,stat),)
 return marshal.dumps(out)
 
+security.declareProtected(ftp_access, 'manage_hasId')
 def manage_hasId(self, REQUEST):
  check if the folder has an object with REQUEST['id'] 
 

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


[Zope-Checkins] SVN: Zope/trunk/ - LP #143722: Added missing permission to ObjectManager.manage_hasId,

2010-07-14 Thread Jens Vagelpohl
Log message for revision 114739:
  - LP #143722: Added missing permission to ObjectManager.manage_hasId,
which prevented renaming files and folders via FTP.
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/OFS/ObjectManager.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===
--- Zope/trunk/doc/CHANGES.rst  2010-07-14 12:08:07 UTC (rev 114738)
+++ Zope/trunk/doc/CHANGES.rst  2010-07-14 12:11:11 UTC (rev 114739)
@@ -11,6 +11,9 @@
 Bugs Fixed
 ++
 
+- LP #143722: Added missing permission to ObjectManager.manage_hasId,
+  which prevented renaming files and folders via FTP.
+
 - LP #143564: Request.resolve_url did not correctly re-raise
   exceptions encountered during path traversal.
 

Modified: Zope/trunk/src/OFS/ObjectManager.py
===
--- Zope/trunk/src/OFS/ObjectManager.py 2010-07-14 12:08:07 UTC (rev 114738)
+++ Zope/trunk/src/OFS/ObjectManager.py 2010-07-14 12:11:11 UTC (rev 114739)
@@ -726,6 +726,7 @@
 out=out+((k,stat),)
 return marshal.dumps(out)
 
+security.declareProtected(ftp_access, 'manage_hasId')
 def manage_hasId(self, REQUEST):
  check if the folder has an object with REQUEST['id'] 
 

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


[Zope-Checkins] SVN: Zope/branches/2.12/ - LP #143533: Instead of showing 0.0.0.0 as server name when no

2010-07-14 Thread Jens Vagelpohl
Log message for revision 114741:
  - LP #143533: Instead of showing 0.0.0.0 as server name when no
specific listening IP is configured for the HTTP server, do a
socket lookup to show the current server's fully qualified name.
  

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/ZServer/HTTPServer.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===
--- Zope/branches/2.12/doc/CHANGES.rst  2010-07-14 14:17:45 UTC (rev 114740)
+++ Zope/branches/2.12/doc/CHANGES.rst  2010-07-14 14:19:15 UTC (rev 114741)
@@ -11,6 +11,10 @@
 Bugs Fixed
 ++
 
+- LP #143533: Instead of showing 0.0.0.0 as server name when no
+  specific listening IP is configured for the HTTP server, do a 
+  socket lookup to show the current server's fully qualified name.
+
 - LP #143722: Added missing permission to ObjectManager.manage_hasId,
   which prevented renaming files and folders via FTP.
 

Modified: Zope/branches/2.12/src/ZServer/HTTPServer.py
===
--- Zope/branches/2.12/src/ZServer/HTTPServer.py2010-07-14 14:17:45 UTC 
(rev 114740)
+++ Zope/branches/2.12/src/ZServer/HTTPServer.py2010-07-14 14:19:15 UTC 
(rev 114741)
@@ -447,6 +447,12 @@
 self.shutup=1
 self.fast_listen = fast_listen
 http_server.__init__(self, ip, port, resolver, logger_object)
+if self.server_name == '0.0.0.0':
+# Workaround to set a more descriptive server_name
+try:
+self.server_name = socket.getfqdn()
+except socket.error:
+pass
 self.shutup=0
 self.log_info('%s server started at %s\n'
   '\tHostname: %s\n\tPort: %d' % (

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


[Zope-Checkins] SVN: Zope/trunk/ - LP #143533: Instead of showing 0.0.0.0 as server name when no

2010-07-14 Thread Jens Vagelpohl
Log message for revision 114742:
  - LP #143533: Instead of showing 0.0.0.0 as server name when no
specific listening IP is configured for the HTTP server, do a
socket lookup to show the current server's fully qualified name.
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/ZServer/HTTPServer.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===
--- Zope/trunk/doc/CHANGES.rst  2010-07-14 14:19:15 UTC (rev 114741)
+++ Zope/trunk/doc/CHANGES.rst  2010-07-14 14:20:18 UTC (rev 114742)
@@ -11,6 +11,10 @@
 Bugs Fixed
 ++
 
+- LP #143533: Instead of showing 0.0.0.0 as server name when no
+  specific listening IP is configured for the HTTP server, do a
+  socket lookup to show the current server's fully qualified name.
+
 - LP #143722: Added missing permission to ObjectManager.manage_hasId,
   which prevented renaming files and folders via FTP.
 

Modified: Zope/trunk/src/ZServer/HTTPServer.py
===
--- Zope/trunk/src/ZServer/HTTPServer.py2010-07-14 14:19:15 UTC (rev 
114741)
+++ Zope/trunk/src/ZServer/HTTPServer.py2010-07-14 14:20:18 UTC (rev 
114742)
@@ -447,6 +447,12 @@
 self.shutup=1
 self.fast_listen = fast_listen
 http_server.__init__(self, ip, port, resolver, logger_object)
+if self.server_name == '0.0.0.0':
+# Workaround to set a more descriptive server_name
+try:
+self.server_name = socket.getfqdn()
+except socket.error:
+pass
 self.shutup=0
 self.log_info('%s server started at %s\n'
   '\tHostname: %s\n\tPort: %d' % (

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


[Zope-Checkins] SVN: Zope/branches/2.12/ - LP #143755: Also catch TypeError when trying to determine an

2010-07-14 Thread Jens Vagelpohl
Log message for revision 114746:
  - LP #143755: Also catch TypeError when trying to determine an
indexable value for an object in PluginIndexes.common.UnIndex
  

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/Products/PluginIndexes/common/UnIndex.py
  U   Zope/branches/2.12/src/Products/PluginIndexes/common/tests/test_UnIndex.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===
--- Zope/branches/2.12/doc/CHANGES.rst  2010-07-14 14:37:25 UTC (rev 114745)
+++ Zope/branches/2.12/doc/CHANGES.rst  2010-07-14 14:53:25 UTC (rev 114746)
@@ -11,6 +11,9 @@
 Bugs Fixed
 ++
 
+- LP #143755: Also catch TypeError when trying to determine an 
+  indexable value for an object in PluginIndexes.common.UnIndex
+
 - LP #143533: Instead of showing 0.0.0.0 as server name when no
   specific listening IP is configured for the HTTP server, do a 
   socket lookup to show the current server's fully qualified name.

Modified: Zope/branches/2.12/src/Products/PluginIndexes/common/UnIndex.py
===
--- Zope/branches/2.12/src/Products/PluginIndexes/common/UnIndex.py 
2010-07-14 14:37:25 UTC (rev 114745)
+++ Zope/branches/2.12/src/Products/PluginIndexes/common/UnIndex.py 
2010-07-14 14:53:25 UTC (rev 114746)
@@ -272,7 +272,7 @@
 datum = getattr(obj, attr)
 if safe_callable(datum):
 datum = datum()
-except AttributeError:
+except (AttributeError, TypeError):
 datum = _marker
 return datum
 

Modified: 
Zope/branches/2.12/src/Products/PluginIndexes/common/tests/test_UnIndex.py
===
--- Zope/branches/2.12/src/Products/PluginIndexes/common/tests/test_UnIndex.py  
2010-07-14 14:37:25 UTC (rev 114745)
+++ Zope/branches/2.12/src/Products/PluginIndexes/common/tests/test_UnIndex.py  
2010-07-14 14:53:25 UTC (rev 114746)
@@ -46,6 +46,34 @@
 self.assertRaises(ConflictError, unindex.removeForwardIndexEntry,
   'conflicts', 42)
 
+def test_get_object_datum(self):
+from Products.PluginIndexes.common.UnIndex import _marker
+idx = self._makeOne('interesting')
+
+dummy = object()
+self.assertEquals(idx._get_object_datum(dummy, 'interesting'), _marker)
+
+class DummyContent2(object):
+interesting = 'GOT IT'
+dummy = DummyContent2()
+self.assertEquals(idx._get_object_datum(dummy, 'interesting'), 'GOT 
IT')
+
+class DummyContent3(object):
+exc = None
+def interesting(self):
+if self.exc:
+raise self.exc
+return 'GOT IT'
+dummy = DummyContent3()
+self.assertEquals(idx._get_object_datum(dummy, 'interesting'), 'GOT 
IT')
+
+dummy.exc = AttributeError
+self.assertEquals(idx._get_object_datum(dummy, 'interesting'), _marker)
+
+dummy.exc = TypeError
+self.assertEquals(idx._get_object_datum(dummy, 'interesting'), _marker)
+
+
 def test_suite():
 suite = unittest.TestSuite()
 suite.addTest(unittest.makeSuite(UnIndexTests))

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


[Zope-Checkins] SVN: Zope/trunk/ - LP #143755: Also catch TypeError when trying to determine an

2010-07-14 Thread Jens Vagelpohl
Log message for revision 114747:
  - LP #143755: Also catch TypeError when trying to determine an
indexable value for an object in PluginIndexes.common.UnIndex
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/Products/PluginIndexes/common/UnIndex.py
  U   Zope/trunk/src/Products/PluginIndexes/common/tests/test_UnIndex.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===
--- Zope/trunk/doc/CHANGES.rst  2010-07-14 14:53:25 UTC (rev 114746)
+++ Zope/trunk/doc/CHANGES.rst  2010-07-14 14:56:13 UTC (rev 114747)
@@ -11,6 +11,9 @@
 Bugs Fixed
 ++
 
+- LP #143755: Also catch TypeError when trying to determine an 
+  indexable value for an object in PluginIndexes.common.UnIndex
+
 - LP #143533: Instead of showing 0.0.0.0 as server name when no
   specific listening IP is configured for the HTTP server, do a
   socket lookup to show the current server's fully qualified name.

Modified: Zope/trunk/src/Products/PluginIndexes/common/UnIndex.py
===
--- Zope/trunk/src/Products/PluginIndexes/common/UnIndex.py 2010-07-14 
14:53:25 UTC (rev 114746)
+++ Zope/trunk/src/Products/PluginIndexes/common/UnIndex.py 2010-07-14 
14:56:13 UTC (rev 114747)
@@ -272,7 +272,7 @@
 datum = getattr(obj, attr)
 if safe_callable(datum):
 datum = datum()
-except AttributeError:
+except (AttributeError, TypeError):
 datum = _marker
 return datum
 

Modified: Zope/trunk/src/Products/PluginIndexes/common/tests/test_UnIndex.py
===
--- Zope/trunk/src/Products/PluginIndexes/common/tests/test_UnIndex.py  
2010-07-14 14:53:25 UTC (rev 114746)
+++ Zope/trunk/src/Products/PluginIndexes/common/tests/test_UnIndex.py  
2010-07-14 14:56:13 UTC (rev 114747)
@@ -46,6 +46,34 @@
 self.assertRaises(ConflictError, unindex.removeForwardIndexEntry,
   'conflicts', 42)
 
+def test_get_object_datum(self):
+from Products.PluginIndexes.common.UnIndex import _marker
+idx = self._makeOne('interesting')
+
+dummy = object()
+self.assertEquals(idx._get_object_datum(dummy, 'interesting'), _marker)
+
+class DummyContent2(object):
+interesting = 'GOT IT'
+dummy = DummyContent2()
+self.assertEquals(idx._get_object_datum(dummy, 'interesting'), 'GOT 
IT')
+
+class DummyContent3(object):
+exc = None
+def interesting(self):
+if self.exc:
+raise self.exc
+return 'GOT IT'
+dummy = DummyContent3()
+self.assertEquals(idx._get_object_datum(dummy, 'interesting'), 'GOT 
IT')
+
+dummy.exc = AttributeError
+self.assertEquals(idx._get_object_datum(dummy, 'interesting'), _marker)
+
+dummy.exc = TypeError
+self.assertEquals(idx._get_object_datum(dummy, 'interesting'), _marker)
+
+
 def test_suite():
 suite = unittest.TestSuite()
 suite.addTest(unittest.makeSuite(UnIndexTests))

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


[Zope-Checkins] SVN: Zope/branches/2.12/ - refining the fix for LP #143533

2010-07-14 Thread Jens Vagelpohl
Log message for revision 114752:
  - refining the fix for LP #143533

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/ZServer/HTTPServer.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===
--- Zope/branches/2.12/doc/CHANGES.rst  2010-07-14 15:11:40 UTC (rev 114751)
+++ Zope/branches/2.12/doc/CHANGES.rst  2010-07-14 15:12:17 UTC (rev 114752)
@@ -14,9 +14,10 @@
 - LP #143755: Also catch TypeError when trying to determine an 
   indexable value for an object in PluginIndexes.common.UnIndex
 
-- LP #143533: Instead of showing 0.0.0.0 as server name when no
-  specific listening IP is configured for the HTTP server, do a 
-  socket lookup to show the current server's fully qualified name.
+- LP #143533: Instead of showing 0.0.0.0 as the SERVER_NAME 
+  request variable when no specific listening IP is configured for 
+  the HTTP server, do a socket lookup to show the current server's 
+  fully qualified name.
 
 - LP #143722: Added missing permission to ObjectManager.manage_hasId,
   which prevented renaming files and folders via FTP.

Modified: Zope/branches/2.12/src/ZServer/HTTPServer.py
===
--- Zope/branches/2.12/src/ZServer/HTTPServer.py2010-07-14 15:11:40 UTC 
(rev 114751)
+++ Zope/branches/2.12/src/ZServer/HTTPServer.py2010-07-14 15:12:17 UTC 
(rev 114752)
@@ -185,7 +185,7 @@
 env = {}
 env['REQUEST_METHOD']=request.command.upper()
 env['SERVER_PORT']=str(server.port)
-env['SERVER_NAME']=server.server_name
+env['SERVER_NAME']=server.request_server_name
 env['SERVER_SOFTWARE']=server.SERVER_IDENT
 env['SERVER_PROTOCOL']=HTTP/+request.version
 env['channel.creation_time']=request.channel.creation_time
@@ -447,10 +447,12 @@
 self.shutup=1
 self.fast_listen = fast_listen
 http_server.__init__(self, ip, port, resolver, logger_object)
-if self.server_name == '0.0.0.0':
-# Workaround to set a more descriptive server_name
+self.request_server_name = self.server_name
+if self.request_server_name == '0.0.0.0':
+# Workaround to set a more descriptive server name
+# for use in the Request SERVER_NAME variable
 try:
-self.server_name = socket.getfqdn()
+self.request_server_name = socket.getfqdn()
 except socket.error:
 pass
 self.shutup=0

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


[Zope-Checkins] SVN: Zope/trunk/ - refining the fix for LP #143533

2010-07-14 Thread Jens Vagelpohl
Log message for revision 114753:
  - refining the fix for LP #143533

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/ZServer/HTTPServer.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===
--- Zope/trunk/doc/CHANGES.rst  2010-07-14 15:12:17 UTC (rev 114752)
+++ Zope/trunk/doc/CHANGES.rst  2010-07-14 15:13:44 UTC (rev 114753)
@@ -14,9 +14,10 @@
 - LP #143755: Also catch TypeError when trying to determine an 
   indexable value for an object in PluginIndexes.common.UnIndex
 
-- LP #143533: Instead of showing 0.0.0.0 as server name when no
-  specific listening IP is configured for the HTTP server, do a
-  socket lookup to show the current server's fully qualified name.
+- LP #143533: Instead of showing 0.0.0.0 as the SERVER_NAME 
+  request variable when no specific listening IP is configured for 
+  the HTTP server, do a socket lookup to show the current server's 
+  fully qualified name.
 
 - LP #143722: Added missing permission to ObjectManager.manage_hasId,
   which prevented renaming files and folders via FTP.

Modified: Zope/trunk/src/ZServer/HTTPServer.py
===
--- Zope/trunk/src/ZServer/HTTPServer.py2010-07-14 15:12:17 UTC (rev 
114752)
+++ Zope/trunk/src/ZServer/HTTPServer.py2010-07-14 15:13:44 UTC (rev 
114753)
@@ -185,7 +185,7 @@
 env = {}
 env['REQUEST_METHOD']=request.command.upper()
 env['SERVER_PORT']=str(server.port)
-env['SERVER_NAME']=server.server_name
+env['SERVER_NAME']=server.request_server_name
 env['SERVER_SOFTWARE']=server.SERVER_IDENT
 env['SERVER_PROTOCOL']=HTTP/+request.version
 env['channel.creation_time']=request.channel.creation_time
@@ -447,10 +447,12 @@
 self.shutup=1
 self.fast_listen = fast_listen
 http_server.__init__(self, ip, port, resolver, logger_object)
-if self.server_name == '0.0.0.0':
-# Workaround to set a more descriptive server_name
+self.request_server_name = self.server_name
+if self.request_server_name == '0.0.0.0':
+# Workaround to set a more descriptive server name
+# for use in the Request SERVER_NAME variable
 try:
-self.server_name = socket.getfqdn()
+self.request_server_name = socket.getfqdn()
 except socket.error:
 pass
 self.shutup=0

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


[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