[Checkins] SVN: z3c.pt/trunk/ - Path expressions give preference to dictionary items instead of

Sidnei da Silva sidnei at enfoldsystems.com
Mon Mar 9 18:56:48 EDT 2009


Log message for revision 97736:
  - Path expressions give preference to dictionary items instead of
    dictionary attributes. [sidnei]
  
  

Changed:
  U   z3c.pt/trunk/CHANGES.txt
  U   z3c.pt/trunk/src/z3c/pt/README.txt
  U   z3c.pt/trunk/src/z3c/pt/expressions.py

-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt	2009-03-09 22:55:13 UTC (rev 97735)
+++ z3c.pt/trunk/CHANGES.txt	2009-03-09 22:56:48 UTC (rev 97736)
@@ -1,6 +1,12 @@
 Changelog
 ---------
 
+1.0b13 (Unreleased)
+~~~~~~~~~~~~~~~~~~~
+
+- Path expressions give preference to dictionary items instead of
+  dictionary attributes. [sidnei]
+
 1.0b12 (2009/03/09)
 ~~~~~~~~~~~~~~~~~~~
 

Modified: z3c.pt/trunk/src/z3c/pt/README.txt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/README.txt	2009-03-09 22:55:13 UTC (rev 97735)
+++ z3c.pt/trunk/src/z3c/pt/README.txt	2009-03-09 22:56:48 UTC (rev 97736)
@@ -283,6 +283,22 @@
     <span>I don't exist?</span>
   </div>
 
+path expression with dictionaries
+---------------------------------
+
+Path expressions give preference to dictionary items instead of
+dictionary attributes.
+
+  >>> print PageTemplate("""\
+  ... <div xmlns="http://www.w3.org/1999/xhtml"
+  ...      tal:define="links python:{'copy':'XXX', 'delete':'YYY'}">
+  ...   <span tal:content="links/copy"
+  ...         >ZZZ</span>
+  ... </div>""")()
+  <div xmlns="http://www.w3.org/1999/xhtml">
+    <span>XXX</span>
+  </div>
+
 TALES Function Namespaces
 -------------------------
 

Modified: z3c.pt/trunk/src/z3c/pt/expressions.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/expressions.py	2009-03-09 22:55:13 UTC (rev 97735)
+++ z3c.pt/trunk/src/z3c/pt/expressions.py	2009-03-09 22:56:48 UTC (rev 97736)
@@ -58,17 +58,17 @@
                         base = self.proxify(traversePathElement(
                             base, name, path_items, request=request))
                         continue
-                    
-                next = getattr(base, name, _marker)
-                if next is not _marker:
-                    base = next
-                    if ns is True and isinstance(base, MethodType):
-                        base = base()
-                    continue
+
+                # special-case dicts for performance reasons
+                if isinstance(base, dict):
+                    base = base[name]
                 else:
-                    # special-case dicts for performance reasons
-                    if isinstance(base, dict):
-                        base = base[name]
+                    next = getattr(base, name, _marker)
+                    if next is not _marker:
+                        base = next
+                        if ns is True and isinstance(base, MethodType):
+                            base = base()
+                        continue
                     else:
                         base = traversePathElement(
                             base, name, path_items, request=request)



More information about the Checkins mailing list