[Zope3-checkins] SVN: Zope3/trunk/ Merge philikon-dtml-sync branch which I worked on *ages* ago and apparently

Philipp von Weitershausen philikon at philikon.de
Fri Apr 28 11:10:49 EDT 2006


Log message for revision 67722:
  Merge philikon-dtml-sync branch which I worked on *ages* ago and apparently
  never merged. zope.sequencesort is a copy of Zope 2's DocumentTemplate.sequence.
  Zope 2.10 will make use of that.
  

Changed:
  U   Zope3/trunk/releases/Zope/DEPENDENCIES.cfg
  U   Zope3/trunk/src/zope/documenttemplate/dt_util.py
  U   Zope3/trunk/src/zope/documenttemplate/dt_var.py
  U   Zope3/trunk/src/zope/documenttemplate/tests/testdt_var.py
  A   Zope3/trunk/src/zope/documenttemplate/tests/testustr.py
  A   Zope3/trunk/src/zope/documenttemplate/ustr.py
  A   Zope3/trunk/src/zope/sequencesort/
  U   Zope3/trunk/src/zope/sequencesort/__init__.py
  U   Zope3/trunk/src/zope/sequencesort/ssort.py
  _U  Zope3/trunk/src/zope/sequencesort/tests/

-=-
Modified: Zope3/trunk/releases/Zope/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/releases/Zope/DEPENDENCIES.cfg	2006-04-28 14:57:35 UTC (rev 67721)
+++ Zope3/trunk/releases/Zope/DEPENDENCIES.cfg	2006-04-28 15:10:48 UTC (rev 67722)
@@ -8,6 +8,7 @@
 zope.formlib
 zope.rdb
 zope.sendmail
+zope.sequencesort
 zope.testing
 zope.viewlet
 zope.app

Modified: Zope3/trunk/src/zope/documenttemplate/dt_util.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/dt_util.py	2006-04-28 14:57:35 UTC (rev 67721)
+++ Zope3/trunk/src/zope/documenttemplate/dt_util.py	2006-04-28 15:10:48 UTC (rev 67722)
@@ -18,13 +18,14 @@
 import re
 
 from types import ListType, StringType, TupleType
+from cgi import escape
 
 # These imports are for the use of clients of this module, as this
 # module is the canonical place to get them. 
 from zope.documenttemplate.pdocumenttemplate import TemplateDict, InstanceDict
 from zope.documenttemplate.pdocumenttemplate import render_blocks
+from zope.documenttemplate.ustr import ustr
 
-
 class ParseError(Exception):
     '''Document Template Parse Error'''
 
@@ -32,17 +33,9 @@
     '''Unauthorized'''
 
 
-def html_quote(v, name='(Unknown name)', md={},
-               character_entities=(
-                       (('&'),    '&'),
-                       (('<'),    '&lt;' ),
-                       (('>'),    '&gt;' ),
-                       (('"'),    '&quot;'))): #"
-    text = str(v)
-    for re, name in character_entities:
-        text = text.replace(re, name)
-    return text
 
+def html_quote(v, name='(Unknown name)', md={}):
+    return escape(ustr(v), 1)
 
 def int_param(params, md, name, default=0):
     try:

Modified: Zope3/trunk/src/zope/documenttemplate/dt_var.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/dt_var.py	2006-04-28 14:57:35 UTC (rev 67721)
+++ Zope3/trunk/src/zope/documenttemplate/dt_var.py	2006-04-28 15:10:48 UTC (rev 67722)
@@ -148,6 +148,7 @@
 $Id$
 """
 from zope.documenttemplate.dt_util import parse_params, name_param, html_quote
+from zope.structuredtext import stx2htmlWithReferences
 import re, sys
 from urllib import quote, quote_plus
 
@@ -372,12 +373,8 @@
     return thousands_commas(str(len(v)))
 
 
-StructuredText = None
 def structured_text(v, name='(Unknown name)', md={}):
-    global StructuredText
-    if StructuredText is None:
-        import StructuredText
-    return str(StructuredText.html_with_references(str(v), 3))
+    return stx2htmlWithReferences(str(v), level=3, header=0)
 
 
 def sql_quote(v, name='(Unknown name)', md={}):
@@ -395,10 +392,9 @@
     'whole-dollars': whole_dollars,
     'dollars-and-cents': dollars_and_cents,
     'collection-length': len_format,
-    # TODO: Gone for now
-    # 'structured-text': structured_text,
+    'structured-text': structured_text,
 
-    # The rest are depricated:
+    # The rest are deprecated:
     'sql-quote': sql_quote,
     'html-quote': html_quote,
     'url-quote': url_quote,

Modified: Zope3/trunk/src/zope/documenttemplate/tests/testdt_var.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/tests/testdt_var.py	2006-04-28 14:57:35 UTC (rev 67721)
+++ Zope3/trunk/src/zope/documenttemplate/tests/testdt_var.py	2006-04-28 15:10:48 UTC (rev 67722)
@@ -42,8 +42,9 @@
             multi:    <dtml-var spam fmt=multi-line>
             dollars:  <dtml-var spam fmt=whole-dollars>
             cents:    <dtml-var spam fmt=dollars-and-cents>
-            dollars,: <dtml-var spam fmt=dollars-with-commas>
-            cents,:   <dtml-var spam fmt=dollars-and-cents-with-commas>
+            dollars:  <dtml-var spam fmt=dollars-with-commas>
+            cents:    <dtml-var spam fmt=dollars-and-cents-with-commas>
+            stx:      <dtml-var spam fmt=structured-text>
 
             """)
 
@@ -55,8 +56,9 @@
             multi:    4200000
             dollars:  $4200000
             cents:    $4200000.00
-            dollars,: $4,200,000
-            cents,:   $4,200,000.00
+            dollars:  $4,200,000
+            cents:    $4,200,000.00
+            stx:      <p>4200000</p>
 
             """)
 
@@ -70,8 +72,9 @@
             multi:    None
             dollars:\x20\x20
             cents:\x20\x20\x20\x20
-            dollars,:\x20
-            cents,:\x20\x20\x20
+            dollars:\x20\x20
+            cents:\x20\x20\x20\x20
+            stx:      <p>None</p>
 
             """)
 
@@ -83,14 +86,16 @@
             multi:    <a href="spam"><br>\nfoo bar
             dollars:\x20\x20
             cents:\x20\x20\x20\x20
-            dollars,:\x20
-            cents,:\x20\x20\x20
+            dollars:\x20\x20
+            cents:\x20\x20\x20\x20
+            stx:      <p><a href="spam">\nfoo bar</p>
 
             """)
 
-        self.assertEqual(html(spam=4200000), result1)
-        self.assertEqual(html(spam=None), result2)
-        self.assertEqual(html(spam=u'<a href="spam">\nfoo bar'), result3)
+        self.assertEqual(html(spam=4200000).strip(), result1.strip())
+        self.assertEqual(html(spam=None).strip(), result2.strip())
+        self.assertEqual(html(spam=u'<a href="spam">\nfoo bar').strip(),
+                         result3.strip())
 
 
     def testRender(self):

Copied: Zope3/trunk/src/zope/documenttemplate/tests/testustr.py (from rev 67720, Zope3/branches/philikon-dtml-sync/src/zope/documenttemplate/tests/testustr.py)

Copied: Zope3/trunk/src/zope/documenttemplate/ustr.py (from rev 67720, Zope3/branches/philikon-dtml-sync/src/zope/documenttemplate/ustr.py)

Copied: Zope3/trunk/src/zope/sequencesort (from rev 67720, Zope3/branches/philikon-dtml-sync/src/zope/sequencesort)


Property changes on: Zope3/trunk/src/zope/sequencesort
___________________________________________________________________
Name: svn:ignore
   + *so
*.pyc
build


Modified: Zope3/trunk/src/zope/sequencesort/__init__.py
===================================================================
--- Zope3/branches/philikon-dtml-sync/src/zope/sequencesort/__init__.py	2006-04-28 14:01:48 UTC (rev 67720)
+++ Zope3/trunk/src/zope/sequencesort/__init__.py	2006-04-28 15:10:48 UTC (rev 67722)
@@ -11,4 +11,4 @@
 #
 ##############################################################################
 
-from ssort import sort
+from zope.sequencesort.ssort import sort

Modified: Zope3/trunk/src/zope/sequencesort/ssort.py
===================================================================
--- Zope3/branches/philikon-dtml-sync/src/zope/sequencesort/ssort.py	2006-04-28 14:01:48 UTC (rev 67720)
+++ Zope3/trunk/src/zope/sequencesort/ssort.py	2006-04-28 15:10:48 UTC (rev 67722)
@@ -124,6 +124,8 @@
     return sequence
 
 
+SortEx = sort
+
 basic_type={type(''): 1, type(0): 1, type(0.0): 1, type(()): 1, type([]): 1,
             type(None) : 1 }.has_key
 



More information about the Zope3-Checkins mailing list