[Checkins] SVN: zope.tal/branches/pypyzpt/src/zope/tal/ extension
module does compile; but cannot be imported
Godefroid Chapelle
gotcha at bubblenet.be
Mon Jun 11 12:02:38 EDT 2007
Log message for revision 76614:
extension module does compile; but cannot be imported
Changed:
U zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/__init__.py
U zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/applevel.py
U zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/interplevel.py
U zope.tal/branches/pypyzpt/src/zope/tal/talinterpreter.py
U zope.tal/branches/pypyzpt/src/zope/tal/talpypy/test/__init__.py
A zope.tal/branches/pypyzpt/src/zope/tal/talutils.py
-=-
Modified: zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/__init__.py
===================================================================
--- zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/__init__.py 2007-06-11 15:08:38 UTC (rev 76613)
+++ zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/__init__.py 2007-06-11 16:02:37 UTC (rev 76614)
@@ -4,11 +4,12 @@
"""interpreter module."""
interpleveldefs = {
- 'normalize' : 'interplevel.normalize',
+ '_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-11 15:08:38 UTC (rev 76613)
+++ zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/applevel.py 2007-06-11 16:02:37 UTC (rev 76614)
@@ -1,3 +1,4 @@
+"""NOT_RPYTHON"""
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
@@ -11,15 +12,11 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Interpreter for a pre-compiled TAL program.
-$Id$
-"""
import cgi
import sys
-from zope.i18nmessageid import Message
from zope.tal.taldefs import quote, TAL_VERSION, METALError
from zope.tal.taldefs import isCurrentVersion
from zope.tal.taldefs import getProgramVersion, getProgramMode
@@ -28,11 +25,9 @@
import _talinterpreter
-# Avoid constructing this tuple over and over
-I18nMessageTypes = (Message,)
+from zope.tal.talutils import isI18nMessageTypes
+from zope.tal.talutils import isTypesToTranslate
-TypesToTranslate = I18nMessageTypes + (str, unicode)
-
BOOLEAN_HTML_ATTRS = frozenset([
# List of Boolean attributes in HTML that should be rendered in
# minimized form (e.g. <img ismap> rather than <img ismap="">)
@@ -47,8 +42,9 @@
_nulljoin = ''.join
_spacejoin = ' '.join
+def normalize(value):
+ return _talinterpreter._normalize(value)
-
class MacroStackItem(object):
def __init__(self, macroName, slots, definingName, extending, entering, i18nContext):
self.macroName = macroName
@@ -443,7 +439,7 @@
translated = self.translate(msgid or value, value)
if translated is not None:
value = translated
- elif isinstance(value, I18nMessageTypes):
+ elif isI18nMessageTypes(value):
translated = self.translate(value)
if translated is not None:
value = translated
@@ -573,7 +569,7 @@
if text is self.Default:
self.interpret(stuff[1])
return
- if isinstance(text, I18nMessageTypes):
+ if isI18nMessageTypes(text):
# Translate this now.
text = self.translate(text)
self._writeText(text)
@@ -585,7 +581,7 @@
if text is self.Default:
self.interpret(stuff[1])
else:
- if isinstance(text, TypesToTranslate):
+ if isTypesToTranslate(text):
text = self.translate(text)
self._writeText(text)
@@ -605,7 +601,7 @@
if self.html and self._currentTag == "pre":
value = tmpstream.getvalue()
else:
- value = _talinterpreter.normalize(tmpstream.getvalue())
+ value = normalize(tmpstream.getvalue())
finally:
self.restoreState(state)
else:
@@ -620,7 +616,7 @@
value = self.engine.evaluate(expression)
# evaluate() does not do any I18n, so we do it here.
- if isinstance(value, I18nMessageTypes):
+ if isI18nMessageTypes(value):
# Translate this now.
value = self.translate(value)
@@ -668,7 +664,7 @@
if self.html and currentTag == "pre":
msgid = default
else:
- msgid = _talinterpreter.normalize(default)
+ msgid = normalize(default)
self.i18nStack.pop()
# See if there is was an i18n:data for msgid
if len(stuff) > 2:
@@ -695,7 +691,7 @@
if structure is self.Default:
self.interpret(block)
return
- if isinstance(structure, I18nMessageTypes):
+ if isI18nMessageTypes(structure):
text = self.translate(structure)
else:
text = unicode(structure)
@@ -715,7 +711,7 @@
if structure is self.Default:
self.interpret(block)
else:
- if not isinstance(structure, TypesToTranslate):
+ if not isTypesToTranslate(structure):
structure = unicode(structure)
text = self.translate(structure)
if not (repldict or self.strictinsert):
Modified: zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/interplevel.py
===================================================================
--- zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/interplevel.py 2007-06-11 15:08:38 UTC (rev 76613)
+++ zope.tal/branches/pypyzpt/src/zope/tal/_talinterpreter/interplevel.py 2007-06-11 16:02:37 UTC (rev 76614)
@@ -1,10 +1,14 @@
from pypy.interpreter.baseobjspace import ObjSpace
-def normalize(space, text):
+
+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())
+ text = text.replace('\n', ' ')
+ text = text.replace('\t', ' ')
+ parts = [part for part in text.split(' ') if part]
+ result = ' '.join(parts)
return space.wrap(result)
-normalize.unwrap_spec = [ObjSpace, str]
+_normalize.unwrap_spec = [ObjSpace, str]
Modified: zope.tal/branches/pypyzpt/src/zope/tal/talinterpreter.py
===================================================================
--- zope.tal/branches/pypyzpt/src/zope/tal/talinterpreter.py 2007-06-11 15:08:38 UTC (rev 76613)
+++ zope.tal/branches/pypyzpt/src/zope/tal/talinterpreter.py 2007-06-11 16:02:37 UTC (rev 76614)
@@ -1,8 +1,10 @@
try:
from pypy.interpreter.mixedmodule import testmodule
- _talinterpreter = testmodule('_talinterpreter', 'zope.tal')
+ rptalinterpreter = testmodule('rptalinterpreter', 'zope.tal')
except ImportError:
- import _talinterpreter
+ import rptalinterpreter
-normalize = _talinterpreter.normalize
-TALInterpreter = _talinterpreter.TALInterpreter
+
+normalize = rptalinterpreter.normalize
+TALInterpreter = rptalinterpreter.TALInterpreter
+
Modified: zope.tal/branches/pypyzpt/src/zope/tal/talpypy/test/__init__.py
===================================================================
--- zope.tal/branches/pypyzpt/src/zope/tal/talpypy/test/__init__.py 2007-06-11 15:08:38 UTC (rev 76613)
+++ zope.tal/branches/pypyzpt/src/zope/tal/talpypy/test/__init__.py 2007-06-11 16:02:37 UTC (rev 76614)
@@ -9,4 +9,5 @@
}
appleveldefs = {
+ 'appfunc' : 'appzpt.appfunc',
}
Added: zope.tal/branches/pypyzpt/src/zope/tal/talutils.py
===================================================================
--- zope.tal/branches/pypyzpt/src/zope/tal/talutils.py (rev 0)
+++ zope.tal/branches/pypyzpt/src/zope/tal/talutils.py 2007-06-11 16:02:37 UTC (rev 76614)
@@ -0,0 +1,11 @@
+from zope.i18nmessageid import Message
+
+I18nMessageTypes = (Message,)
+TypesToTranslate = I18nMessageTypes + (str, unicode)
+
+def isI18nMessageTypes(value):
+ return isinstance(value, I18nMessageTypes)
+
+def isTypesToTranslate(value):
+ return isinstance(value, TypesToTranslate)
+
More information about the Checkins
mailing list