[Checkins] SVN: zope.tal/branches/pypyzpt/src/zope/tal/ normalize is now interp level code

Godefroid Chapelle gotcha at bubblenet.be
Wed Jun 6 11:42:01 EDT 2007


Log message for revision 76428:
  normalize is now interp level code

Changed:
  A   zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/
  U   zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/__init__.py
  U   zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/applevel.py
  A   zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/interplevel.py
  D   zope.tal/branches/pypyzpt/src/zope/tal/talinterpreter/
  U   zope.tal/branches/pypyzpt/src/zope/tal/tests/test_talinterpreter.py

-=-
Copied: zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter (from rev 76424, zope.tal/branches/pypyzpt/src/zope/tal/talinterpreter)

Modified: zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/__init__.py
===================================================================
--- zope.tal/branches/pypyzpt/src/zope/tal/talinterpreter/__init__.py	2007-06-06 14:33:28 UTC (rev 76424)
+++ zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/__init__.py	2007-06-06 15:41:55 UTC (rev 76428)
@@ -4,9 +4,11 @@
     """interpreter module."""
 
     interpleveldefs = {
+        'normalize' : 'interplevel.normalize',
     }
 
     appleveldefs = {
         'TALInterpreter' : 'applevel.TALInterpreter',
-        'normalize' : 'applevel.normalize',
     }
+
+

Modified: zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/applevel.py
===================================================================
--- zope.tal/branches/pypyzpt/src/zope/tal/talinterpreter/applevel.py	2007-06-06 14:33:28 UTC (rev 76424)
+++ zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/applevel.py	2007-06-06 15:41:55 UTC (rev 76428)
@@ -26,6 +26,7 @@
 from zope.tal.translationcontext import TranslationContext
 from zope.tal.alttalgenerator import AltTALGenerator
 
+import _talinterpreter
 
 # Avoid constructing this tuple over and over
 I18nMessageTypes = (Message,)
@@ -46,14 +47,8 @@
 _nulljoin = ''.join
 _spacejoin = ' '.join
 
-def normalize(text):
-    # Now we need to normalize the whitespace in implicit message ids and
-    # implicit $name substitution values by stripping leading and trailing
-    # whitespace, and folding all internal whitespace to a single space.
-    return _spacejoin(text.split())
 
 
-
 class MacroStackItem(object):
     def __init__(self, macroName, slots, definingName, extending, entering, i18nContext):
         self.macroName = macroName
@@ -610,7 +605,7 @@
                 if self.html and self._currentTag == "pre":
                     value = tmpstream.getvalue()
                 else:
-                    value = normalize(tmpstream.getvalue())
+                    value = _talinterpreter.normalize(tmpstream.getvalue())
             finally:
                 self.restoreState(state)
         else:
@@ -673,7 +668,7 @@
             if self.html and currentTag == "pre":
                 msgid = default
             else:
-                msgid = normalize(default)
+                msgid = _talinterpreter.normalize(default)
         self.i18nStack.pop()
         # See if there is was an i18n:data for msgid
         if len(stuff) > 2:

Added: zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/interplevel.py
===================================================================
--- zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/interplevel.py	                        (rev 0)
+++ zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/interplevel.py	2007-06-06 15:41:55 UTC (rev 76428)
@@ -0,0 +1,10 @@
+from pypy.interpreter.baseobjspace import ObjSpace
+
+def normalize(space, text):
+    # Now we need to normalize the whitespace in implicit message ids and
+    # implicit $name substitution values by stripping leading and trailing
+    # whitespace, and folding all internal whitespace to a single space.
+    result = ' '.join(text.split())
+    return space.wrap(result)
+normalize.unwrap_spec = [ObjSpace, str]
+

Modified: zope.tal/branches/pypyzpt/src/zope/tal/tests/test_talinterpreter.py
===================================================================
--- zope.tal/branches/pypyzpt/src/zope/tal/tests/test_talinterpreter.py	2007-06-06 15:37:01 UTC (rev 76427)
+++ zope.tal/branches/pypyzpt/src/zope/tal/tests/test_talinterpreter.py	2007-06-06 15:41:55 UTC (rev 76428)
@@ -29,7 +29,7 @@
 
 #from zope.tal.talinterpreter import TALInterpreter
 from pypy.interpreter.mixedmodule import testmodule
-talinterpreter =  testmodule('talinterpreter', 'zope.tal')
+talinterpreter =  testmodule('_talinterpreter', 'zope.tal')
 TALInterpreter = talinterpreter.TALInterpreter
 
 from zope.tal.talgenerator import TALGenerator



More information about the Checkins mailing list