--- DT_Util.py.orig Tue Mar 14 23:36:13 2000 +++ DT_Util.py Wed Mar 15 23:49:40 2000 @@ -106,6 +106,25 @@ if find(text, re) >= 0: text=join(split(text,re),name) return text +def script_quote(v, name='(Unknown name)', md={}): + """Quotes every string sufficiently so that javascript likes us. + Should work for tclscript too. + + This is needed if we, for example, want to use rendered docouments + in script strings. + """ + find_offenders = regex.compile('[\,\n,",\',/]').search + if find_offenders(v) > -1: + if find(v,"\\") > -1: v = join(split(v,"\\"),"\\\\") + if find(v,"\n") > -1: v = join(split(v,"\n"),"\\n") + if find(v,"\r") > -1: v = join(split(v,"\r"),"\\r") + if find(v,"\"") > -1: v = join(split(v,"\""),"\\\"") + if find(v,"\'") > -1: v = join(split(v,"\'"),"\\\'") + if find(v,"/") > -1: v = join(split(v,"/"),"\\/") + return v + else: + return v + def int_param(params,md,name,default=0, st=type('')): try: v=params[name] except: v=default