Commit 6400a7a9 authored by Jim Fulton's avatar Jim Fulton

Removed old validation machinery.

parent a8955db9
...@@ -68,19 +68,6 @@ Document templates support conditional and sequence insertion ...@@ -68,19 +68,6 @@ Document templates support conditional and sequence insertion
%(In)s %(In)s
Accessibility of names:
The programmer of a module can specify the visibility of all
attributes available to a Document Template editor in two ways. A
mapping object whose keys are accessible attributes and whose
values are short descriptions can be passed to the document
template. Any name not appearing as a key in that list will not
be acecssible from the document template. In addition to, or as
an alternative to, the mapping object, a validation function can
be specified. The validation function takes the name and the
value of the attribute being accessed as arguments and returns a
non-zero result if the access is allowed.
Document Templates may be created 4 ways: Document Templates may be created 4 ways:
DocumentTemplate.String -- Creates a document templated from a DocumentTemplate.String -- Creates a document templated from a
...@@ -213,7 +200,7 @@ HTML__doc__="""HTML Document Templates ...@@ -213,7 +200,7 @@ HTML__doc__="""HTML Document Templates
<!--#/if args--> <!--#/if args-->
And I'm 100% sure! And I'm 100% sure!
</body></html> </body></html>
''', __names__={'num':'number', 'arg':'argument'})(aa) ''')(aa)
# This is a basic example of batch processing. # This is a basic example of batch processing.
...@@ -257,10 +244,7 @@ HTML__doc__="""HTML Document Templates ...@@ -257,10 +244,7 @@ HTML__doc__="""HTML Document Templates
<!--#/in inventory--> <!--#/in inventory-->
</dl> </dl>
</body></html> </body></html>
''', __names__={'dealer':'Dealer name', ''')
'make':'Make of car',
'model':'Car model',
'year':'Year of manufacture'})
print html(inventory=RDB.File("dealer-inventory.rdb"), first_car=18) print html(inventory=RDB.File("dealer-inventory.rdb"), first_car=18)
...@@ -311,10 +295,7 @@ HTML__doc__="""HTML Document Templates ...@@ -311,10 +295,7 @@ HTML__doc__="""HTML Document Templates
<!--#/in inventory--> <!--#/in inventory-->
</dl> </dl>
</body></html> </body></html>
''', __names__={'dealer':'Dealer name', ''')
'make':'Make of car',
'model':'Car model',
'year':'Year of manufacture'})
print html(inventory=RDB.File("dealer-inventory.rdb"), first_car=18) print html(inventory=RDB.File("dealer-inventory.rdb"), first_car=18)
......
__doc__='''Machinery to support through-the-web editing __doc__='''Machinery to support through-the-web editing
$Id: DT_UI.py,v 1.2 1997/09/02 19:04:52 jim Exp $''' $Id: DT_UI.py,v 1.3 1997/10/27 17:37:13 jim Exp $'''
############################################################################ ############################################################################
# Copyright # Copyright
...@@ -55,7 +55,7 @@ $Id: DT_UI.py,v 1.2 1997/09/02 19:04:52 jim Exp $''' ...@@ -55,7 +55,7 @@ $Id: DT_UI.py,v 1.2 1997/09/02 19:04:52 jim Exp $'''
# (540) 371-6909 # (540) 371-6909
# #
############################################################################ ############################################################################
__version__='$Revision: 1.2 $'[11:-2] __version__='$Revision: 1.3 $'[11:-2]
from DT_HTML import HTML from DT_HTML import HTML
...@@ -109,35 +109,11 @@ HTML._manage_editForm = HTML( ...@@ -109,35 +109,11 @@ HTML._manage_editForm = HTML(
</center> </center>
</FORM> </FORM>
<!--#if vars-->
<p>The following variables may be used in this template:</p>
<table border>
<tr>
<th>Variables
<th>Description
<!--#in vars-->
<tr>
<td><!--#var sequence-key--></td>
<td><!--#var __str__--></td>
</tr>
<!--#/in vars-->
</table>
<!--#/if vars-->
<BR CLEAR="ALL"> <BR CLEAR="ALL">
<!--#var document_template_edit_footer--> <!--#var document_template_edit_footer-->
</BODY> </BODY>
</HTML>""", #" </HTML>""",)
__names__={
'HTTP_REFERER':'Referring URL',
'PARENT_URL':"This page's parent",
'document_template_edit_header':"(internal)",
'document_template_edit_footer':"(internal)",
'__str__':"(internal)",
'vars':'list of DTML variables you can manipulate',
'descrip':'desciption of DTML variables you can manipulate',
})
HTML.editConfirmation=HTML( HTML.editConfirmation=HTML(
"""<html><head><title>Change Successful</title></head><body> """<html><head><title>Change Successful</title></head><body>
...@@ -152,14 +128,13 @@ HTML.editConfirmation=HTML( ...@@ -152,14 +128,13 @@ HTML.editConfirmation=HTML(
<center> <center>
<em><!--#var dt_edit_name--></em><br>has been changed. <em><!--#var dt_edit_name--></em><br>has been changed.
</center> </center>
<!--#/if CANCEL_ACTION-->""",#" <!--#/if CANCEL_ACTION-->""")
__names__={
'CANCEL_ACTION':'???',
'PARENT_URL':"This page's parent",
})
############################################################################ ############################################################################
# $Log: DT_UI.py,v $ # $Log: DT_UI.py,v $
# Revision 1.3 1997/10/27 17:37:13 jim
# Removed old validation machinery.
#
# Revision 1.2 1997/09/02 19:04:52 jim # Revision 1.2 1997/09/02 19:04:52 jim
# Got rid of ^Ms # Got rid of ^Ms
# #
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"""Document Template Tests """Document Template Tests
""" """
__rcs_id__='$Id: DTtest.py,v 1.1 1997/08/27 18:55:44 jim Exp $' __rcs_id__='$Id: DTtest.py,v 1.2 1997/10/27 17:40:02 jim Exp $'
############################################################################ ############################################################################
# Copyright # Copyright
...@@ -56,7 +56,7 @@ __rcs_id__='$Id: DTtest.py,v 1.1 1997/08/27 18:55:44 jim Exp $' ...@@ -56,7 +56,7 @@ __rcs_id__='$Id: DTtest.py,v 1.1 1997/08/27 18:55:44 jim Exp $'
# (540) 371-6909 # (540) 371-6909
# #
############################################################################ ############################################################################
__version__='$Revision: 1.1 $'[11:-2] __version__='$Revision: 1.2 $'[11:-2]
from DocumentTemplate import * from DocumentTemplate import *
import sys import sys
...@@ -116,7 +116,7 @@ def test1(): ...@@ -116,7 +116,7 @@ def test1():
%(else args)] %(else args)]
And thats da trooth. And thats da trooth.
</body></html> </body></html>
""", __names__={'args':'args', 'num':1}) """)
print ss(aa) print ss(aa)
...@@ -160,7 +160,7 @@ def test2(): ...@@ -160,7 +160,7 @@ def test2():
<!--#/if values--> <!--#/if values-->
And I\'m 100% sure! And I\'m 100% sure!
</body></html> </body></html>
''',__names__={'values':'doc'})(aa) ''')(aa)
def test3(): def test3():
test2() test2()
...@@ -194,7 +194,7 @@ def test3(): ...@@ -194,7 +194,7 @@ def test3():
<!--#/if args--> <!--#/if args-->
And I\'m 100% sure! And I\'m 100% sure!
</body></html> </body></html>
''', __validator__=test3_okay) ''')
size,orphan=5,0 size,orphan=5,0
for end in range(20): for end in range(20):
...@@ -312,19 +312,10 @@ def test4(): ...@@ -312,19 +312,10 @@ def test4():
<!--#/in inventory--> <!--#/in inventory-->
</dl> </dl>
</body></html> </body></html>
''', __validator__=test4_okay) ''')
print html(inventory=items, first_ad=15) print html(inventory=items, first_ad=15)
def test4_okay(key, val):
global cache
try: x = cache
except NameError: cache = {}
if not cache.has_key(key):
print 'Validating', key
cache[key] = 1
return 1
def test5(): def test5():
html=HTML( html=HTML(
'''\ '''\
...@@ -357,7 +348,7 @@ def test5(): ...@@ -357,7 +348,7 @@ def test5():
</CENTER> </CENTER>
</body> </body>
</html>''',__names__={'affiliates':'empty', 'PARENT_URL':'www'}) </html>''')
print html(affiliates=[], PARENT_URL='www') print html(affiliates=[], PARENT_URL='www')
...@@ -392,7 +383,7 @@ def test6(): ...@@ -392,7 +383,7 @@ def test6():
--------------- ---------------
<!--#/if sequence-end--> <!--#/if sequence-end-->
<!--#/in data--> <!--#/in data-->
""",__names__={'data':'list of names and ages'}) """)
print html(data=data) print html(data=data)
def test7(): def test7():
...@@ -411,14 +402,9 @@ def test8(): ...@@ -411,14 +402,9 @@ def test8():
%(name capitalize spacify)s is %(name capitalize spacify)s is
%(date fmt=year)s/%(date fmt=month)s/%(date fmt=day)s %(date fmt=year)s/%(date fmt=month)s/%(date fmt=day)s
""") """)
html.validator(test8_okay)
print html(date=DateTime.DateTime(), print html(date=DateTime.DateTime(),
name='todays_date') name='todays_date')
def test8_okay(key, val):
print 'Validating', key
return 1
def test9(): def test9():
html=HTML( html=HTML(
""" """
...@@ -427,12 +413,10 @@ def test9(): ...@@ -427,12 +413,10 @@ def test9():
<!--#var sequence-item--> <!--#var sequence-item-->
<!--#/in sequence-item--> <!--#/in sequence-item-->
<!--#/in spam--> <!--#/in spam-->
""",__names__={'spam':'spam'}) """)
html.validator(test8_okay)
print html(spam=[[1,2,3],[4,5,6]]) print html(spam=[[1,2,3],[4,5,6]])
def test9a(): def test9a():
# no name validation - should raise KeyError...
html=HTML( html=HTML(
""" """
<!--#in spam--> <!--#in spam-->
...@@ -448,7 +432,7 @@ def test10(): ...@@ -448,7 +432,7 @@ def test10():
html=HTML( html=HTML(
""" """
<!--#var spam fmt="$%.2f bob's your uncle" null="spam%eggs!|"--> <!--#var spam fmt="$%.2f bob's your uncle" null="spam%eggs!|"-->
""",__names__={'spam':'spam'}) #" """)
print html(spam=42) print html(spam=42)
print html(spam=None) print html(spam=None)
#print html(spam=Missing.Value) #print html(spam=Missing.Value)
...@@ -467,7 +451,7 @@ def test11(): ...@@ -467,7 +451,7 @@ def test11():
dollars,: <!--#var spam fmt=dollars-with-commas--> dollars,: <!--#var spam fmt=dollars-with-commas-->
cents,: <!--#var spam fmt=dollars-and-cents-with-commas--> cents,: <!--#var spam fmt=dollars-and-cents-with-commas-->
""",__names__={'spam':'spam'}) """)
print html(spam=4200000) print html(spam=4200000)
print html(spam=None) print html(spam=None)
...@@ -548,6 +532,9 @@ if __name__ == "__main__": ...@@ -548,6 +532,9 @@ if __name__ == "__main__":
############################################################################ ############################################################################
# $Log: DTtest.py,v $ # $Log: DTtest.py,v $
# Revision 1.2 1997/10/27 17:40:02 jim
# Removed old validation machinery.
#
# Revision 1.1 1997/08/27 18:55:44 jim # Revision 1.1 1997/08/27 18:55:44 jim
# initial # initial
# #
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment