[Baypiggies] Python Frameworks
keith at dartworks.biz
Wed Oct 28 05:44:27 CET 2009
=== On Tue, 10/27, Jeremy Fishman wrote: ===
> Sorry if I left anyone's favorite project out,
Hey, I'll take this opportunity to plug one I'm writing.
The pycopia.WWW.framework has the following differentiating features:
Clean URL scheme
URL mappings in one place.
Leverage "web 2.0"- AJAX/JSON
Reversible URLs (map handler to URL)
No threads, SMP scalable
Quick and easy to write and deploy
The reason I am doing this is the following. I wanted a framework that
could be used to put a "web interface" on an small-scale PC or PC based
network appliance-type device. Most of those other frameworks tend
toward being database interfaces, run in one process with threads, and
can't interface to the system very well.
The Pycopia web framework is designed as a collection of smaller
servers, each one may run with different user credentials and use the
FCGI protocol to communicate to the front-end, which is a single
lighttpd server. These are mapped to a single, clean URL tree and is
transparent to the client. This is done to separate privileges to only
those parts of the web application that need it. For example, to edit a
database a back-end FCGI server runs as a pseudo-user that has
privileges to access the database, and only that. Another back-end
might need to control a particular device node and therefore needs
another user and/or group credentials. Another part may need to run a
program as the logged in user. Since the web server itself does not run
as that user some part needs to run as root and than perform the
equivalent of the login program to spawn a subprocess with the user
Since the URL path tree is farmed out to different handler processes
the whole system can benefit more from SMP systems.
The URL scheme uses regular expressions to map a URL to a handler.
The handler may take parameters. This works a lot like Django. However,
you can also do the reverse by calling the get_url() method with the
target object (plus optional parameters) and will return the URL that
will reach it exactly that way. Therefore you don't have to hard-code
paths in the code which makes re-arranging your tree and handlers
I don't like templates. I prefer to work purely with Python code.
Therefore there is an XHTML markup generator system that looks a lot
like some GUI frameworks (e.g. Tk), but constructs XHTML documents
However, the use of server-side generated XHTML markup is discouraged.
Instead, only the first App page is generated. Most of the rest of the
The Pycopia framework provides a data interface using JSON
serialization and a Proxy object that transparently calls server-side
side take basic Python objects as parameters and return Python objects.
going to the server, handled there and returns a value that the
There is no mandated Database or ORM. I use Sqlalchemy for that when I
need to access a database. There is a generic forms builder for that.
There is also a database JSON API handled by an instance of the above
mentioned proxy object.
The framework also inherently handles host-based virtual servers. You
can serve many host/domains from the single server, and each domain may
run a separate set of back-end handlers.
There are several different handler patterns that may be used. Supports
any callable object. Bare functions, or a subclass of a special handler
class can be used. The handler subclass just defines get() and post()
methods to handle forms.
I eat my own dogfood. There's not much content, by my websites use this
framework. All of www.pycopia.org, www.pycopia.net, www.dartworks.biz,
and www.kdart.com (and more) are run from one instance of this
Thanks for listening. Give a whirl if you're interested.
-- Keith Dart
<keith at dartworks.biz>
More information about the Baypiggies