Re: [Zope] trailing whitespace optimization
Fellas, I got it to work :) I used the rstrip method from the string module to trim trailing whitespace from the end of each line whenever a document template gets saved. I tested it with DTML Documents and Methods, which both worked fine. It doesn't affect properties, so if you need to render trailing whitespace for some reason you could store that as a property. The mods are listed below. If you use it, let me know what you think and I'll write it up. Cheers, -Paul - Trim Trailing Whitespace Optomization - There were two changes to one file. \lib\DocumentTemplate\DT_String.py -from string import split, strip +from string import split, strip, rstrip ... def munge(self,source_string=None,mapping=None,**vars): """\ Change the text or default values for a document template. """ +""" Optomization start - trim trailing whitespace to reduce file sizes by 10-50% """ +my_lines=split(source_string,'\n') +my_source='' +for my_line in my_lines:my_source=my_source+rstrip(my_line)+'\n' +source_string=my_source +""" Optomization end """ if mapping is not None or vars: self.initvars(mapping, vars) if source_string is not None: self.raw=source_string self.cook() - --- Tino Wildenhain <[EMAIL PROTECTED]> wrote: > > > Gregory Haley wrote: > > > > Hi Paul, > > > > You're right about the size of files with trailing > blanks. > > I had a file of over 1 meg yesterday, and when I > striped all > > the blanks it was only 47K, pretty radical reduction. > > > > There is an external Python method that is part of the > zope > > Extenions library, it should be in something called > > /opt/zope/Extensions/ called strip_blanks.py. You can > > attach it to your zope session, then it is called via: > > > > > > > Is this the same as calling "_.string.strip(varName)"> > only slower? ;-) > > Regards > Tino Wildenhain > > > __ Do You Yahoo!? Get Yahoo! Mail Free email you can access from anywhere! http://mail.yahoo.com/ ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] trailing whitespace optimization
Gregory Haley wrote: > > Hi Paul, > > You're right about the size of files with trailing blanks. > I had a file of over 1 meg yesterday, and when I striped all > the blanks it was only 47K, pretty radical reduction. > > There is an external Python method that is part of the zope > Extenions library, it should be in something called > /opt/zope/Extensions/ called strip_blanks.py. You can > attach it to your zope session, then it is called via: > > > Is this the same as calling only slower? ;-) Regards Tino Wildenhain ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] trailing whitespace optimization
Hi Paul, You're right about the size of files with trailing blanks. I had a file of over 1 meg yesterday, and when I striped all the blanks it was only 47K, pretty radical reduction. There is an external Python method that is part of the zope Extenions library, it should be in something called /opt/zope/Extensions/ called strip_blanks.py. You can attach it to your zope session, then it is called via: This will at least strip all the trailing blanks from an individual variable. ciao! greg. Gregory Haley venaca.com Paul Abrams wrote: > > I'm noticing that our file sizes could be reduced by 10% or > more by trimming trailing whitespace. Is there a way to get > Zope to do that automatically? It would be best if Zope did > it whenever a method was saved. > > Thanks in advance, > -Paul > > __ > Do You Yahoo!? > Get Yahoo! Mail - Free email you can access from anywhere! > http://mail.yahoo.com/ > > ___ > Zope maillist - [EMAIL PROTECTED] > http://lists.zope.org/mailman/listinfo/zope > ** No cross posts or HTML encoding! ** > (Related lists - > http://lists.zope.org/mailman/listinfo/zope-announce > http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] trailing whitespace optimization
On Tue, 11 Jul 2000, Paul Abrams wrote: > I'm noticing that our file sizes could be reduced by 10% or > more by trimming trailing whitespace. Is there a way to get > Zope to do that automatically? It would be best if Zope did > it whenever a method was saved. Agreed. I have found that reformatting can save much space. However, sometimes you might actually WANT those spaces there. I know, HTML is supposed to ignore whitespace, but there could be various reasons you would want to keep trailing spaces. Really, your best solution is to stop being to slack, and remove the spaces yourself! (o8 > > Thanks in advance, > -Paul > Have a better one, Curtis Maloney. ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] trailing whitespace optimization
I'm noticing that our file sizes could be reduced by 10% or more by trimming trailing whitespace. Is there a way to get Zope to do that automatically? It would be best if Zope did it whenever a method was saved. Thanks in advance, -Paul __ Do You Yahoo!? Get Yahoo! Mail Free email you can access from anywhere! http://mail.yahoo.com/ ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )