[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/module/manager.py Use encode() instead of str() for module names

Ross Patterson me at rpatterson.net
Tue Feb 6 13:28:06 EST 2007


Log message for revision 72401:
  Use encode() instead of str() for module names
  
  As per philikon's feedback:
  http://mail.zope.org/pipermail/checkins/2007-February/006213.html
  

Changed:
  U   Zope3/trunk/src/zope/app/module/manager.py

-=-
Modified: Zope3/trunk/src/zope/app/module/manager.py
===================================================================
--- Zope3/trunk/src/zope/app/module/manager.py	2007-02-06 16:10:07 UTC (rev 72400)
+++ Zope3/trunk/src/zope/app/module/manager.py	2007-02-06 18:28:05 UTC (rev 72401)
@@ -92,9 +92,12 @@
                         zope.component.interfaces.IRegistered)
 def setNameOnActivation(manager, event):
     """Set the module name upon registration activation."""
-    # Convert the name to a normal string to avoid problems with
-    # unicode module names
-    manager.name = str(event.object.name)
+    name = event.object.name
+    if not isinstance(event.object.name, str):
+        # Convert the name to an ascii string to avoid problems with
+        # unicode module names
+        name = name.encode('ascii', 'ignore')
+    manager.name = name
 
 @zope.component.adapter(IModuleManager,
                         zope.component.interfaces.IUnregistered)



More information about the Zope3-Checkins mailing list