[Zope] Little change of DT_Var.py for dtml-var modification
Jaroslav Lukesh
lukesh at seznam.cz
Fri Nov 21 05:40:49 EST 2003
> Odesílatel: Dieter Maurer <dieter at handshake.de>
> Jaroslav Lukesh wrote at 2003-11-20 13:43 +0100:
> > 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.
> Jaroslav Lukesh wrote at 2003-11-20 13:43 +0100:
> Your "cut" handling comes a bit late:
>
> Code after a "return" is ineffective....
Many thanks for your effective help. In attachment I send modified
DT_Var.py file (from Zope 2.5.1) with this new function called "cut" and
"etcc" (see below, extracted from comments).
Attribute 'cut' will continue from number of cutted bytes:
<!--#var spam cut=12--> inserts '... blah blah'
After truncation, the value given for the 'etcc' attribute is added
to
the string. If the 'etcc' attribute is not provided, then '...'
is used.
Here are equivalent word-break as in 'size', but in reverse order
for no missing words or letters.
Both 'size' and 'cut' could be used for middle text extraction:
'<dtml-var spam cut=3 size=10>' first make text shorter fot 10 bytes
(as specified in 'size') and then from this shortened text
was cutted first 3 bytes (as specified in 'cut').
So result text length is in adequate to 'size - cut'
with respect to word breaks.
Because I am not an experienced python programmer, I feel, that code could
be rewritten to consume less memory. But it works nice and I think that it
would be usefull if it will be present in newer Zope versions too.
For easy reference, see lines 177 and 287-311 of that new code.
Best Regards,
J. Lukesh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DT_Var.py.gz
Type: application/octet-stream
Size: 5164 bytes
Desc: DT_Var.py.gz (Aladdin StuffIt Archive)
Url : http://lists.zope.org/pipermail/zope/attachments/20031121/4c65dbd6/DT_Var.py.obj
More information about the Zope
mailing list