[Zope] Little change of DT_Var.py for dtml-var modification
Jaroslav Lukesh
lukesh at seznam.cz
Thu Nov 20 07:43:47 EST 2003
Hallo all,
I want to add parameter "cut=###" to <dtml-var> tag. It is opposite for
"size" parameter, at Zope 2.5.1 you can find it around line 260 of
DT_Var.py.
But after restart (*.pyc file successfully created) the modified tag
<dtml-var file cut=200>
does not cut anything, returns whole text from file instead file with
missing first 200 chars...
Does somebody have idea, where I need to change more?
Many thanks, J. Lukesh
DT_Var.py:
if have_arg('size'):
size=args['size']
try: size=int(size)
except: raise 'Document Error',(
'''a <code>size</code> attribute was used in a
<code>var</code>
tag with a non-integer value.''')
if len(val) > size:
val=val[:size]
l=val.rfind(' ')
if l > size/2:
val=val[:l+1]
if have_arg('etc'): l=args['etc']
else: l='...'
val=val+l
return val
# added 'cut', opposite derivate from 'size'
if have_arg('cut'):
cut=args['cut']
try: cut=int(cut)
except: raise 'Document Error',(
'''a <code>cut</code> attribute was used in a
<code>var</code>
tag with a non-integer value.''')
if len(val) > cut:
val=val[cut:]
l=val.rfind(' ')
if l > cut/2:
val=val[:l+1]
if have_arg('etc'): l=args['etc']
else: l='...'
val=l+val
return val
And I have defined here (around line 160)
def __init__(self, args, fmt='s'):
if args[:4]=='var ': args=args[4:]
args = parse_params(args, name='', lower=1, upper=1, expr='',
capitalize=1, spacify=1, null='', fmt='s',
size=0, cut=0, etc='...', thousands_commas=1,
html_quote=1, url_quote=1, sql_quote=1,
url_quote_plus=1, missing='',
newline_to_br=1, url=1)
More information about the Zope
mailing list