Quixote: a Python-Centric Web Application Framework
Quixote is a web application framework for Python programmers. It was primarily developed by Andrew Kuchling, Neil Schemenauer and myself (Greg Ward) at the MEMS Exchange, in order to make our real job—the creation of a web-driven network of semiconductor fabrication sites—easier. For the development of our main web site (www.mems-exchange.org), we needed to concentrate on the complex business logic needed for such a network and draw a clear line between the backend and the user interface. We also wanted to use Python as much as possible, because in our opinion it is the most appropriate language for such a complex and rapidly changing application domain.
Quixote requires Python 2.0 or greater, a good understanding of Python and a web server that implements the CGI protocol. (Although your applications will be much happier using a mechanism, such as FastCGI or SCGI, that allows long-running web processes.)
Quixote was written by and for Python programmers who need to develop dynamic web sites while using as much of their existing Python knowledge as possible. In particular, Quixote is not very accommodating of the commonly made distinction between “web designers” and “web developers”. If the web designers at your organization are keen to try out a real programming language, then Quixote might provide them with a good introduction to Python; but anyone who doesn't understand what “import a module” or “call a function” means isn't going to get very far with Quixote. Similarly, anyone who expects to use a dedicated, WYSIWYG HTML editor for creating web pages will be left out.
This, incidentally, is completely opposite to the stance taken by most other web application frameworks, which is precisely why we don't like most other web application frameworks. In our limited experience, they all invent an HTML templating language that embeds some sort of programming language in HTML, often with deliberate limitations to prevent naive users from shooting themselves in the feet. This usually ends up being painful and frustrating for programmers who want power and flexibility and are perfectly capable of aiming the gun away from their own feet.
Specifically, Quixote's templating language, PTL (Python Template Language), inverts the usual model by making it easier for Python code to generate long text strings such as HTML documents, rather than by embedding Python code in an HTML-like template language. We'll cover PTL in more detail later.
Quixote might be the tool for you if:
you need to develop dynamic web sites with complex programming needs, either in the backend or for presentation/user interfaces;
you're more concerned with providing good content and getting the logic behind the site right than you are with fancy design tricks;
you don't want to learn (and fight with) yet another HTML-templating language; and/or
you want to use everything you already know about Python (modules, packages, functions, classes and so forth) to develop web sites
Quixote is built on four core principles:
Publishing function results: Quixote's main job is using a URL to look up a Python callable (e.g., a function or method) and put its results on the web.
The URL is part of the user interface, and the organization of source code and URL-space should roughly correspond.
Embedding HTML in Python is cleaner and easier than embedding Python in HTML.
No magic: when Quixote can't figure out what to do, it refuses to guess the programmer's intent, preferring to raise an exception instead.
The usual way to develop a Quixote application is to write a set of classes that implement the fundamental logic of your system—variously referred to as domain classes, domain objects, business logic and so forth. Your domain classes ideally should have nothing to do with the type of user interface you're going to implement. Then you implement the web interface as a separate set of PTL modules. The relationship between these two bodies of code should be entirely one-way: the web interface will import and rely heavily on the domain classes, but the domain classes will be completely ignorant of the web interface.
As a real-world example, consider SPLAT!, a simple bug-tracking tool I wrote as a sample Quixote application (and also because we needed a simple bug tracker). SPLAT! (named for the sound of a bug being squashed) consists of a Python package, splat, with a sub-package called splat.web. The domain classes, SPLAT!'s idea of what a bug is, what a user is, how its bugs are stored, are in modules named things like splat.bug, splat.user, splat.database and so on.
The web interface to SPLAT! is implemented in the splat.web package, with the following modules:
splat.web.util (splat/web/util.ptl) splat.web.index (splat/web/index.ptl) splat.web.bug_ui (splat/web/bug_ui.ptl) splat.web.prefs (splat/web/prefs.ptl)
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- Google's SwiftShader Released
- SUSE LLC's SUSE Manager
- My +1 Sword of Productivity
- Managing Linux Using Puppet
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- Interview with Patrick Volkerding
- Non-Linux FOSS: Caffeine!
- SuperTuxKart 0.9.2 Released
- Tech Tip: Really Simple HTTP Server with Python
- Parsing an RSS News Feed with a Bash Script
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide