Back to index

plone3  3.1.7
Classes | Functions | Variables
plone.memoize.compress Namespace Reference

Classes

class  XHTMLSlimmer

Functions

def xhtml_compress

Variables

 SLIMMER = True
tuple xhtmlslimmer = XHTMLSlimmer()

Detailed Description

In order to use Peter Bengtsson's slimmer library available from
http://www.issuetrackerproduct.com/Download#slimmer
you need to register the XHTMLSlimmer utility like this:

  <utility component="plone.memoize.compress.xhtmlslimmer"
           provides="plone.memoize.interfaces.IXHTMLCompressor" />

You can register other XHTML-whitespace removal libraries as well.

Per default there is no compressor available and we get the same string back:

   >>> html_string = u"<html><body><SPAN>Hello.</SPAN></body><html>"
   >>> xhtml_compress(html_string) is html_string
   True

Make a stupid lowercasing compressor. This is not safe as it would lowercase
all text outside of tags as well:

   >>> class LowerCaser(object):
   ...     implements(IXHTMLCompressor)
   ...
   ...     def compress(self, string):
   ...         return string.lower()

   >>> lower = LowerCaser()

Register our new compressor:

   >>> from zope.component import getSiteManager
   >>> sm = getSiteManager()
   >>> sm.registerUtility(lower)

   >>> xhtml_compress(html_string)
   u'<html><body><span>hello.</span></body><html>'

Function Documentation

Definition at line 50 of file compress.py.

00050 
00051 def xhtml_compress(string):
00052     util = queryUtility(IXHTMLCompressor)
00053     if util is not None:
00054         return util.compress(string)
00055     return string
00056 

Here is the caller graph for this function:


Variable Documentation

Definition at line 43 of file compress.py.

Definition at line 66 of file compress.py.