opental-checkins
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[OpenTAL-checkins] opental/pax paxtransform.py utils.py


From: Fernando Lalo Martins
Subject: [OpenTAL-checkins] opental/pax paxtransform.py utils.py
Date: Mon, 14 Apr 2003 18:13:03 -0400

CVSROOT:        /cvsroot/opental
Module name:    opental
Changes by:     Fernando Lalo Martins <address@hidden>  03/04/14 18:13:02

Modified files:
        pax            : paxtransform.py utils.py 

Log message:
        fixing the refactoring

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/opental/opental/pax/paxtransform.py.diff?tr1=1.32&tr2=1.33&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/opental/opental/pax/utils.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text

Patches:
Index: opental/pax/paxtransform.py
diff -u opental/pax/paxtransform.py:1.32 opental/pax/paxtransform.py:1.33
--- opental/pax/paxtransform.py:1.32    Mon Apr 14 17:06:17 2003
+++ opental/pax/paxtransform.py Mon Apr 14 18:13:02 2003
@@ -5,7 +5,7 @@
 from backwards_compatibility import *
 from utils import pack_list, XML
 from core import Literal
-import types
+import types, sys, traceback
 
 class StopTransform(Exception):
     def __init__(self, result=None, *args):
@@ -55,6 +55,7 @@
             result = pack_list(result)
         except:
             # usually we're not interested in errors from pack
+            traceback.print_exc()
             pass
         context.postprocess_remaining = processed
         try:
@@ -119,15 +120,17 @@
     "Transforms something, and renders it to XML"
     def transform(self, element, context):
         result = Engine.transform(self, element, context)
-        return XML(result, context.root_xmlns_map, context.encoding)
+        if hasattr(result, 'children'):
+            return XML(result, context.root_xmlns_map, context.encoding)
+        elif type(result) in (types.ListType, types.TupleType):
+            return ''.join([str(child) for child in result])
+        return result
 
     def transform_children(self,element,context):
         element = Engine.transform_children(self, element, context)
         # except that the children will be strings
         if hasattr(element, 'children'):
-            element.children = (Literal(''.join(element)),)
-        elif type(element) in (types.ListType, types.TupleType):
-            element = Literal(''.join(element))
+            element.children = (Literal(''.join([str(child) for child in 
element if child])),)
         return element
 
 
Index: opental/pax/utils.py
diff -u opental/pax/utils.py:1.11 opental/pax/utils.py:1.12
--- opental/pax/utils.py:1.11   Sun Apr 13 09:03:15 2003
+++ opental/pax/utils.py        Mon Apr 14 18:13:02 2003
@@ -40,8 +40,9 @@
     "remove Nones, expand tuples"
     if hasattr(self, 'join'):
         return self
-    if hasattr(self, pack):
-        return self.pack()
+    if hasattr(self, 'pack'):
+        self.pack()
+        return self
     is_tuple = type(self) is types.TupleType
     result = []
     for child in self:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]