[Checkins] SVN: five.pt/trunk/ Add same_type

Wichert Akkerman wichert at wiggy.net
Wed Sep 29 10:14:46 EDT 2010


Log message for revision 117062:
  Add same_type

Changed:
  U   five.pt/trunk/CHANGES.txt
  U   five.pt/trunk/src/five/pt/pagetemplate.py

-=-
Modified: five.pt/trunk/CHANGES.txt
===================================================================
--- five.pt/trunk/CHANGES.txt	2010-09-29 13:06:24 UTC (rev 117061)
+++ five.pt/trunk/CHANGES.txt	2010-09-29 14:14:45 UTC (rev 117062)
@@ -1,12 +1,19 @@
 Changelog
 =========
 
+1.3.2 - 2010-09-29
+~~~~~~~~~~~~~~~~~~
+
+- Add a same_type method to the default namespace.
+  [wichert]
+
 1.3.1 - 2010-09-23
 ~~~~~~~~~~~~~~~~~~
 
 - Added support for eager loading (environment variable
   ``CHAMELEON_EAGER``). This flag should be passed only in development
   mode and will reveal any templates which do not parse.
+  [malthe]
 
 1.3 - 2010-09-08
 ~~~~~~~~~~~~~~~~

Modified: five.pt/trunk/src/five/pt/pagetemplate.py
===================================================================
--- five.pt/trunk/src/five/pt/pagetemplate.py	2010-09-29 13:06:24 UTC (rev 117061)
+++ five.pt/trunk/src/five/pt/pagetemplate.py	2010-09-29 14:14:45 UTC (rev 117062)
@@ -16,6 +16,17 @@
     if method is not None:
         return method()
 
+def same_type(arg1, *args):
+    """Compares the class or type of two or more objects. Copied from
+    RestrictedPython.
+    """
+    t = getattr(arg1, '__class__', type(arg1))
+    for arg in args:
+        if getattr(arg, '__class__', type(arg)) is not t:
+            return False
+    return True
+
+
 def test(condition, a, b):
     if condition:
         return a
@@ -48,6 +59,7 @@
                 here=context,
                 container=context,
                 nothing=None,
+                same_type=same_type,
                 test=test,
                 path=pagetemplate.evaluate_path,
                 exists=pagetemplate.evaluate_exists,



More information about the checkins mailing list