Saturday, November 7, 2009

Early release of PySiteCreator - v0.1

By Vasudev Ram

Hi readers,

I've released a tool for creating HTML pages or Web sites by writing them in Python - PySiteCreator v0.1.

Description of PySiteCreator:

PySiteCreator is a tool that allows the user to create Web (HTML) sites by writing them entirely in Python. A user creates one or more Python source files in each of which they import a PySiteCreator helper module, and then call helper functions defined in that module, in order to emit HTML elements and associated content. They can then run the PySiteCreator program to process all those Python files; processing each Python file will result in the creation of a corresponding HTML file with the desired HTML elements and content.

A useful feature of PySiteCreator is that it allows you to write almost any Python code you wish, that can fetch data from any source, for outputting to the created HTML files. The data can be fetched from text files, CSV files, DBM files, any type of file in the file system from which you can fetch data by any means, from a relational database using the Python DB API, from any source on the Internet, using sockets, XML-RPC calls, HTTP REST calls, SOAP calls, CORBA, PYRO, RPyC, or any other suitable method.

There are only a few conventions to be followed, such as importing the psc_util module in each Python file your write, and defining a top-level function in each file, that should be named create(), in order to be able to use PySiteCreator. Other than those conventions, there are no other restrictions or requirements about what kind of code you write in the Python files.

UPDATE: The PySiteCreator documentation is a bit sketchy at present (basically, a README.txt file), but I'll be improving it over the course of the next several days. Meanwhile, there are examples in the examples subdirectory of the package; viewing them will make it easy for anyone with reasonable Python skills to understand how to use PySiteCreator. The examples show a few different ways of using PySiteCreator - not just basic HTML element generation, but other things, like conditional HTML output, passing JavaScript through, linking to other pages, getting data via Mark Pilgrim's FeedParser, etc.

Requirements for PySiteCreator:

- The only software requirement for running PySiteCreator is Python
itself. PySiteCreator has been developed and tested using Python
v2.6.1. It may also work with some earlier versions of Python, particularly fairly recent ones like 2.5.x or 2.4.x.

You can get PySiteCreator from here:

Vasudev Ram - Dancing Bison Enterprises


Anonymous said...

Showing an example of what a piece of code that generated HTML would be helpful.

Without that, I'm not going to even bother downloading.

Shopping Cart said...

It mean that it gives all development facilities in one.

Vasudev Ram said...

Your comment is ungrammatical. Had to figure out what it meant.

Check the examples directory in the zip file - it has both code examples and the HTML output they generate. Also remember this is v0.1 stuff.

Vasudev Ram said...

To clarify: My comment above (about grammar and the examples directory) was in reply to the first commenter, Anonymous, above.

Ravi said...

wouldn't it be better if you made a GUI for this? Otherwise, if someone can code in python, he/she can definitely write some HTML!

Vasudev Ram said...

@Ravi: Dude. Did you even bother to read the example in the PySiteCreator zip file, or read this post properly? Also, check out jekyll, hyde and other similar projects.

Vasudev Ram said...

@Ravi: Also, to make it more clear: can you do if-then-else statements in HTML? Can you write for or while loops, or define functions and call them, in HTML? Can you fetch a feed's contents using FeedParser (mentioned clearly in the post) using just HTML ??? If you can, you must be a genius. For us mere mortals, it requires a programming language.