- In fact, we might avoid hardcoding HTML in our script completely if we use one
of the HTML generator tools we’ll meet later, including HTMLgen (a system for
creating HTML from document object trees) and PSP (Python Server Pages, a
server-side HTML templating system for Python similar to PHP and ASP). - For ease of maintenance, it might also be better to split the CGI script’s HTML
code off to a separate file in order to better divide display from logic (different
parties with possibly different skill sets could work on the different files). - Moreover, if this website might be accessed by many people simultaneously, we
would have to add file locking or move to a database such as ZODB or MySQL to
support concurrent updates. ZODB and other full-blown database systems would
also provide transaction rollbacks in the event of failures. For basic file locking,
the os.open call and its flags provide the tools we need. - ORMs (object relational mappers) for Python such as SQLObject and SQLAlchemy
mentioned earlier might also allow us to gain concurrent update support of an
underlying relational database system, but retain our Python class view of the data. - In the end, if our site grows much beyond a few interactive pages, we might also
migrate from basic CGI scripting to a more complete web framework such as one
of those mentioned at the start of this section— Django, TurboGears, pyjamas,
and others. If we must retain information across pages, tools such as cookies, hid-
den inputs, mod_python session data, and FastCGI may help too. - If our site eventually includes content produced by its own users, we might tran-
sition to Plone, a popular open source Python- and Zope-based site builder that,
using a workflow model, delegates control of site content to its producers. - And if wireless or cloud interfaces are on our agenda, we might eventually migrate
our system to cell phones using a Python port such as those available for scripting
Nokia platforms and Google’s Android, or to a cloud-computing platform such as
Google’s Python-friendly App Engine. Python tends to go wherever technology
trends lead.
For now, though, both the GUI and web-based interfaces we’ve coded get the job done.
The End of the Demo
And that concludes our sneak preview demo of Python in action. We’ve explored data
representation, OOP, object persistence, GUIs, and website basics. We haven’t studied
any of these topics in any great depth. Hopefully, though, this chapter has piqued your
curiosity about Python applications programming.
In the rest of this book, we’ll delve into these and other application programming tools
and topics, in order to help you put Python to work in your own programs. In the next
chapter, we begin our tour with the systems programming and administration tools
available to Python programmers.
The End of the Demo | 69