You can also do:

def compress_response(d):
    if not isinstance(d,dict): return d
    import scripts.cleanhtml
    return scripts.cleanhtml.cleanhtml(response.render(d))



On Dec 29, 8:06 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
> Currently I am using the following, works perfect for my applications...
>
> import re
>
> def save_pre(match):
>     s = match.group()
>     if s.startswith('<pre') \
>        or s.startswith('<textarea') \
>        or s.startswith('<blockquote'):
>         pass
>     else:
>         s = ''
>     return s
>
> def compress_response(d):
>     if not isinstance(d,dict):  d = d()
>     cpat = 
> re.compile(r'[\n\t\r\f\v]|(?s)\s\s\s|(?s)<pre(.*?)</pre>|(?s)<blockquote(.*?)</blockquote>|(?s)<textarea(.*?)</textarea>')
>     dd = cpat.sub(save_pre, response.render(d))
>     lgh = latest_guppy_heapy()
>     return dd
>
> if request.controller not in ['',] \
>    and request.function not in ['error','preview_markdown',
> 'download', 'call', 'raw_download']:
>     response._caller = compress_response
>
> -Thadeus
>
> On Tue, Dec 29, 2009 at 6:58 PM, Jonathan Lundell <jlund...@pobox.com> wrote:
> > On Dec 15, 2009, at 3:23 PM, mdipierro wrote:
>
> >> You may also want to look into scripts/cleanhtml.py and scripts/
> >> cleancss.py.
>
> > cleanhtml.py would benefit from some comments....
>
> > --
>
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.
>
>

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to