spyce
home
license
community
download
examples
resources
wishlist
contrib (@sf)
documentation
intro
lang
runtime
modules
tags
install
exits
sourceforge
statistics
freshmeat

Spyce Home
[[ Spyce ]]
Python Server Pages
by Rimon Barr

SPYCE is a server-side language that supports simple and efficient Python-based dynamic HTML generation, otherwise called Python Server Pages (PSP). Those who are familiar with JSP, PHP, or ASP and like Python, should have a look at Spyce. Its modular design makes it very flexible and extensible. It can also be used as a command-line utility for static text pre-processing or as a web-server proxy.

Updates
The latest released version of Spyce is: 1.3.13 (download).
Please refer to the change log or the CVS repository for details.

30-seconds sales pitch

  • Spyce is about embedding Python in HTML to create dynamic web pages. If you like Python and you need to create web pages, you'll like Spyce.
  • Spyce is intuitive. Here are a few "Hello world!" examples written in Spyce:

    <html><body>
      Hello [[print 'world!',]]
      [[ for i in range(10): { ]]
        [[=i]]
      [[ } ]]
    </body></html>
    

    [[-- With Spyce lambda's, you can separate code from presentation --]]
    [[
        # Here, we will define a spyce lambda to create a page template
        page = [[spy! title, data:
    <html>
    <head>
      <title>[[=title]]</title>
    </head>
    <body>
      <h1>[[=title]]</h1>
      <table style="text-align:center;">
      [[ for text in data: { ]]
        <tr><td>[[=text]]</td></tr>
      [[ } ]]
      </table>
    </body>
    </html>
        ]]
    ]]
    [[\
        # Here we're using the "Python Chunk" code style
        # we're now going to excute code to fill the values
        # of our template
        import random
        
        title = "Hello World!"
        data = ['<b>Welcome</b>','<b>to</b>','<b>Spyce</b>', \
            random.randint(1, 100000), random.randint(100000000, 999999999)]
    ]]
    [[-- Emit the page --]]
    [[ page(title, data) ]]
    

  • Spyce inherits the syntactic power of Python as well as its rich standard library. All the standard Python modules can be used directly within Spyce scripts.
  • Spyce is modular and extensible. The standard modules include: request, response, redirect, error, debug, include, cookie, session, template, transform, compress, and others. You can write your own, if you like.
  • Spyce supports active tags, i.e. tags that can execute code. They are similar in spirit and functionality to JSP tags, but significantly easier to write. Use the standard tags provided, or write your own custom active tag libraries.
  • Spyce scripts are first-order members of the Spyce language, a useful feature not present in other server page languages. This allows Spyce scripts to be turned into functions, useful for templating, internationalization, polymorphic component rendering, etc.
  • Spyce performs well. It can easily serve hundreds of requests per second, and is comparable with JSP, PHP and other languages in its class.
  • And, we're out of time... You'll have to read the docs for the rest.

Site index


© 2002-07 Rimon Barr
email: rimon@acm.org
Spyce Powered SourceForge Logo [[ Spyce ]]
Python Server Pages
version 1.3.13