[Checkins] SVN: Sandbox/malthe/chameleon.core/ Renamed dynamic scope variable to 'econtext' in order to reduce compatibility issues with ZPT.

Malthe Borch mborch at gmail.com
Tue Nov 18 19:46:31 EST 2008


Log message for revision 93109:
  Renamed dynamic scope variable to 'econtext' in order to reduce compatibility issues with ZPT.

Changed:
  U   Sandbox/malthe/chameleon.core/CHANGES.txt
  U   Sandbox/malthe/chameleon.core/src/chameleon/core/clauses.py
  U   Sandbox/malthe/chameleon.core/src/chameleon/core/codegen.py
  U   Sandbox/malthe/chameleon.core/src/chameleon/core/codegen.txt
  U   Sandbox/malthe/chameleon.core/src/chameleon/core/config.py
  U   Sandbox/malthe/chameleon.core/src/chameleon/core/generation.py
  U   Sandbox/malthe/chameleon.core/src/chameleon/core/utils.py

-=-
Modified: Sandbox/malthe/chameleon.core/CHANGES.txt
===================================================================
--- Sandbox/malthe/chameleon.core/CHANGES.txt	2008-11-18 23:59:33 UTC (rev 93108)
+++ Sandbox/malthe/chameleon.core/CHANGES.txt	2008-11-19 00:46:30 UTC (rev 93109)
@@ -4,6 +4,9 @@
 HEAD
 ~~~~
 
+- Renamed dynamic scope variable to `econtext` in order to reduce
+  compatibility issues with ZPT. [malthe]
+
 - Fixed issue where multiple defines would cause integrity
   issues. [malthe]
 

Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/clauses.py
===================================================================
--- Sandbox/malthe/chameleon.core/src/chameleon/core/clauses.py	2008-11-18 23:59:33 UTC (rev 93108)
+++ Sandbox/malthe/chameleon.core/src/chameleon/core/clauses.py	2008-11-19 00:46:30 UTC (rev 93109)
@@ -1001,7 +1001,7 @@
     >>> from chameleon.core import testing
       
     >>> _out, _write, stream = testing.setup_stream()
-    >>> _scope = {}
+    >>> econtext = {}
     >>> method = Method('test', ('a', 'b', 'c'))
     >>> method.begin(stream)
     >>> stream.write('print a, b, c')

Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/codegen.py
===================================================================
--- Sandbox/malthe/chameleon.core/src/chameleon/core/codegen.py	2008-11-18 23:59:33 UTC (rev 93108)
+++ Sandbox/malthe/chameleon.core/src/chameleon/core/codegen.py	2008-11-19 00:46:30 UTC (rev 93109)
@@ -141,7 +141,7 @@
         # generator expression, leave it alone
         if not node.name in self.names:
             # Otherwise, translate the name ref into a context lookup
-            func_args = [ast.Name('_scope'), ast.Const(node.name)]
+            func_args = [ast.Name('econtext'), ast.Const(node.name)]
             node = ast.CallFunc(ast.Name('_lookup_name'), func_args)
         return node
 

Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/codegen.txt
===================================================================
--- Sandbox/malthe/chameleon.core/src/chameleon/core/codegen.txt	2008-11-18 23:59:33 UTC (rev 93108)
+++ Sandbox/malthe/chameleon.core/src/chameleon/core/codegen.txt	2008-11-19 00:46:30 UTC (rev 93109)
@@ -34,7 +34,7 @@
 ---------------------------------
 
   >>> suite = Suite("""\
-  ... _scope = {'a': 1}
+  ... econtext = {'a': 1}
   ... assert a == 1
   ... """)
   >>> exec suite.code in suite._globals

Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/config.py
===================================================================
--- Sandbox/malthe/chameleon.core/src/chameleon/core/config.py	2008-11-18 23:59:33 UTC (rev 93108)
+++ Sandbox/malthe/chameleon.core/src/chameleon/core/config.py	2008-11-19 00:46:30 UTC (rev 93109)
@@ -38,7 +38,6 @@
     metal = '_metal'
     include = '_include'
     macro = '_macro'
-    scope = '_scope'
     out = '_out'
     tmp = '_tmp'
     write = '_write'
@@ -51,13 +50,14 @@
     negotiate = '_negotiate'
     translate = '_translate'
     validate = '_validate'
-    default = 'default'
     
     # advertised symbols
     repeat = 'repeat'
     language = 'target_language'
     xincludes = 'xincludes'
-    
+    default = 'default'
+    scope = 'econtext'
+
     @classmethod
     def as_dict(cls):
         return dict((name, getattr(cls, name)) for name in dir(cls))

Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/generation.py
===================================================================
--- Sandbox/malthe/chameleon.core/src/chameleon/core/generation.py	2008-11-18 23:59:33 UTC (rev 93108)
+++ Sandbox/malthe/chameleon.core/src/chameleon/core/generation.py	2008-11-19 00:46:30 UTC (rev 93109)
@@ -9,7 +9,7 @@
 def render(%(init)s, %(args)s%(extra)s%(language)s=None):
 \t%(out)s, %(write)s = %(init)s.initialize_stream()
 \t%(attributes)s, %(repeat)s = %(init)s.initialize_tal()
-\t%(scope)s = {}
+\t%(scope)s = %(init)s.initialize_scope()
 \t%(domain)s = None
 
 %(body)s
@@ -58,6 +58,8 @@
     out = BufferIO()
     return (out, out.write)
 
+initialize_scope = utils.econtext
+    
 class BufferIO(list):
     write = list.append
 

Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/utils.py
===================================================================
--- Sandbox/malthe/chameleon.core/src/chameleon/core/utils.py	2008-11-18 23:59:33 UTC (rev 93108)
+++ Sandbox/malthe/chameleon.core/src/chameleon/core/utils.py	2008-11-19 00:46:30 UTC (rev 93109)
@@ -118,6 +118,13 @@
 
     yield '</%s>' % name
 
+class econtext(dict):
+    """Dynamic scope dictionary which is compatible with the
+    `econtext` of ZPT."""
+    
+    set_local = setLocal = dict.__setitem__
+    set_global = setGlobal = dict.__setitem__
+    
 class scope(list):
     def __init__(self, *args):
         global s_counter



More information about the Checkins mailing list