This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Quick Overview

Spats or Simple PAge Template Server is an attempt to make a simple little Page Template Server that can be used by everyone. Basically the idea is simple, allow you to serve out a Page Template back to a http request. It subclass all the Python standard library HTTP servers to do this.

You can also have Python Scripts which are for the more advanced logic of serving out bits and peices.

Dependencies

SimpleTAL, although we might need to make a more complicated one soon to deal with i18n. SimpleTAL can be found here:

http://www.owlfish.com/software/simpleTAL/

Optional Dependencies

wxembed: Using a wxPython to embed the server and IE win to make it look like an application. Requires wx.

mfcembed: Using a win32ui native wrapper to embed the server and IE win to make it look like an application. A better choice for Windows users. Requires pywin32.

taskbar: Makes a little windows taskbar icon. Again only for Windows and requires pywin32.

browser: Just runs in the command line and fires up a browser. No dependencies for this one ;)

Detailed Overview

What is spats?

A SimplePAgeTemplateServer, credit goes to Leo for the name. Basically a way to make a web server, quickly and simply to serve dynamic stuff back to the server.

What does it do?

Serves compiled page templates back to the user. That’s all really, basically it takes the file on the file system and serves it back. If that file happens to be a page template it compiles it with simpletal and then spits it back to the user.

It’s not a CGI server (it doesn’t serve Python scripts back).

It’s not Zope, it doesn’t do any of that stuff Zope does. It’s simple.

It does GET and HEAD, that’s it.

It does not make good cups of tea.

Using

See example.py

Make a directory and put a start.py, that reads:

from spats import SimplePageTemplateServer
SimplePageTemplateServer.start()

This won’t do much however, you need to tell it where to read HTML from. So you can pass a config dictionary variable through of all the possible values.

So make a directory called say html or pt. Stick a PageTemplate, called say index.pt in there. Now pass that directory through and you are on your way:

from spats import SimplePageTemplateServer
config = {"html_dir":"html"}
SimplePageTemplateServer.start(config)

See SimplePageTemplateServer.py for a commented list of variables.

Scripts

Pass through a scripts_dir value in the config, and everything in that dir that: ends in .py and contains a __main__ method will be compiled into the scripts context.

So you can then access in TAL scripts/foo where foo is your script. This will call the __call__ function.

Note: in a script the context will be assigned to the script, this is the context variable in TAL so you can access all TAL variables in the script. See some examples in the reports site.

You do not serve scripts directly, you serve PageTemplates that call scripts.

SimpleTal

This is rather quirky if you are used to Zope TAL, but you should get there quickly. Main quirks:

  • elements have to be closed <p tal:content="foo" /> must be <p tal:content="foo"></p>
  • the context is different because we build that ourselves and it can be tricky
  • attributes errors fail silently which is kinda nice but confusing

But it doesn’t do…?

So add it dude, its only a 200 line module. But keep it simple please, or goal is to be able to throw together things simply and quickly not rebuild Zope.

Change history

0.1 (2008-12-10)

  • Initial release as a Python egg [sidnei].

Contributors

  • Andy McKay
  • Mark Hammond
  • Neil Kandalgoankar

Download

Release History

Release History

0.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
spats-0.1.zip (59.5 kB) Copy SHA256 Checksum SHA256 Source Dec 10, 2008

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting