Picket

The Picket filter is a simple CherryPy filter for processing XSLT as a template language. It uses 4Suite to do the job.

What name is that?

Well, finding name for projects today is becoming almost a task per se. Picket came to my mind at one point (don't ask how...) so I picked it up.

Thanks to

The guys at 4Suite for all their help and support

Download

https://svn.defuze.org/oss/picket/

History

Version 0.7   - Support for XSLT extensions added by Uche Ogbuji and Travis Spencer
                Overall improvements and docstrings by Uche Ogbuji
                The user can now specify a base URL for the XML source
Version 0.0.6 - Support CherryPy 2.2, 
                Added Content Type attribute to the filter and to the Picket class
                Switched public parameters to lower case
Version 0.0.5 - Support new style cherrypy import module
Version 0.0.4 - Added support for CP2.1
Version 0.0.3 - Added the defaultStylesheet argument to the filter
Version 0.0.2 - Brings a better support in multithreading applications
Version 0.0.1 - First release

Examples

test.py

# CherryPy 2.2.x
import cherrypy
from picket import PicketFilter, Picket 

class Root:
      _cp_filter_list = [ PicketFilter() ]

      def index(self):
          picket = Picket()
          picket.stylesheet = "whoami.xsl" 
          return picket
      index.exposed = True

      def sayHello(self, name):
          picket = Picket()
          picket.stylesheet = "picket.xsl" 
          picket.document = file("picket.xml", "r").read()
          picket.parameters['username'] = name
          return picket
      sayHello.exposed = True

if __name__ == '__main__':
   cherrypy.root = Root()
   cherrypy.server.start()

whoami.xsl

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" indent="yes" />

<xsl:template match="*">
  <html>
    <head></head>
    <body>
      <div align="left">
        <form action="/sayHello" method="get">
          What's your name?
          <input type="text" size="10" maxlength="30" name="name"/>
          <input type="submit" />
        </form>
      </div>
    </body>
  </html>
</xsl:template>

</xsl:stylesheet>

picket.xsl

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" indent="yes" />

<xsl:param name="username" select="anonymous"/>

<xsl:template match="*">
  <html>
    <head />
    <body>
      <div align="left">
        <p>Hi <xsl:value-of select="$username" />!</p>
        <p><xsl:value-of select="/gluglu/glo" /></p>
      </div>
    </body>
  </html>
</xsl:template>

</xsl:stylesheet>

picket.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<gluglu>
   <glo>Come on in and have a sit!</glo>
</gluglu>