Running the Pylons Book Examples before Pylons 0.9.7 and SQLAlchemy 0.5 are Released
Posted: | 2008-12-16 16:18 |
---|---|
Tags: | Pylons, Python, Web, SQLAlchemy, Software Releases, Book |
The printed copies of The Definitive Guide to Pylons are due in the Apress warehouse today!
This is very exciting news but as many of you will know the book targets Pylons 0.9.7 and SQLAlchemy 0.5 but these haven't actually been released yet! Both are on Release Candidate 4. This means that in order to run the examples in the book you'll temporarily have to use the release candidate versions until the final releases are made.
This is slightly trickier than simply installing the release candidate versions because you need to trick Python into thinking they are the final versions for the book examples to be completely accurate so in this post I'll show you how to do that. Obviously if you've got hold of the book after the release of Pylons 0.9.7 and SQLAlchemy 0.5, none of this will apply and the Pylons Book examples should work exactly as described in the book, this is only necessary because the book is available before the software it describes.
First of all you'll need to install two software clients: Mercurial and Subversion. There are versions for Windows, Mac OS X and Linux. On Debian or Ubuntu you would do this:
sudo apt-get install subversion mercurial
Next check out the latest code from Pylons and SQLAlchemy source code and modify them with these commands:
hg clone http://pylonshq.com/hg/pylons-dev cd pylons-dev cat <<EOF> setup.cfg [egg_info] #tag_build = dev #tag_svn_revision = true EOF cd .. svn co http://svn.sqlalchemy.org/sqlalchemy/trunk/ SQLAlchemy-dev cd SQLAlchemy-dev echo 0.5.0 > VERSION cat <<EOF> setup.cfg [egg_info] #tag_build = dev #tag_svn_revision = true EOF cd ..
Then edit SQLAlchemy-dev/lib/sqlalchemy.__init__.py so that the __version__ variable at the end reads '0.5.0' so that the Pylons paginator correctly works out the SQLAlchemy version.
Now create your virtual Python environment as normal and install the modified versions of the packages above:
wget http://pylonsbook.com/virtualenv.py python2.5 virtualenv.py env cd pylons-dev ../env/bin/python2.5 setup.py develop cd ../SQLAlchemy-dev/ ../env/bin/python2.5 setup.py develop cd ..
With these changes in place everything else will work correctly. For example you can now go on to install the SimpleSite application. First install the Python database driver you need:
sudo apt-get install sqlite
Then install, configure, set up and serve SimpleSite:
env/bin/easy_install SimpleSite env/bin/paster make-config SimpleSite example.ini env/bin/paster setup-app example.ini env/bin/paster serve example.ini
As long as you have edited example.ini before running paster setup-app to specify the correct database to use and as long as you have the Python driver for that database engine installed, you will then be able to test the running application at http://localhost:5000.
You can then sign in with the username admin and the password opensesame and you have your own simple website with comments, tags, a visual editor and a navigation hierarchy. Easy as that!