ruralmind

test driving TextPress

Fabric: Avoiding deployment tedium

written by avanderlip, on Oct 20, 2008 2:28:00 AM.

I gave a lightning talk at the 2008 Plone Conference on Fabric. To clear up one point immediately, though I presented on Fabric, I did not write it. Fabric is a Python based remote deployment tool. It is similar to Capistrano for ROR but is more generic; it makes no assumptions about the target of the deployment. It is used to automate tasks on remote machines, like updating SVN, restarting Zope clients, etc. Certainly the same can be accomplished using shell scripts, but Fabric provides a common library for creating deployment scripts. It automates the tedium of deploying changes, I have fewer excuses to put off updates.

My colleague Rocky Burt provided me with the following instructions for setting up Fabric:

Note: The following requires Python 2.5 and was written assuming a UNIX-style workstation

Instructions

  1. Install virtualenv for Python 2.5 (if you haven't already)
    1. download http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.1.tar.gz
    2. extract virtualenv-1.1.tar.gz into your favourite directory
  1. Create new virtualenv to contain fabric
    1. cd $HOME # do this in the home dir
    2. python2.5 /some/path/to/virtualenv-1.1/virtualenv.py fabric
  1. Install fabric
    1. cd $HOME/fabric
    2. ./bin/easy_install Fabric
  1. Create directory to house the fabric deployments
    1. cd $HOME/fabric
    2. mkdir fabs

example command

One of the common tasks for development is to download the production Data.fs from a remote server to your local development environment.

def download_datafs():
    """Download the remote Data.fs file to the /tmp dir"""

    fname = '$(fab_timestamp)-www.jazkarta.com-Data.fs'
    fpath = '/tmp/' + fname
    fabcommon.run('cp '+basedir+'/var/filestorage/Data.fs ' + fpath)
    fabcommon.run('bzip2 ' + fpath)

    localfile = '/tmp/'+fname+'.bz2'
    download(fpath+'.bz2', localfile)

    newfile = localfile+'.$(fab_host)'
    targetdir = '/tmp/$(fab_timestamp)-$(fab_host)'
    targetfile = targetdir+'/Data.fs.bz2'
    local_per_host('mkdir -p '+targetdir)
    local_per_host('mv '+newfile+' '+targetfile)
    local_per_host('echo "Downloaded Data.fs to "' + targetfile)
  1. To run this command
    1. cd $HOME/fabric
    2. source ./bin/activate
    3. cd fabs/yoursite.org
    4. fab download_datafs
You can chain commands together so that a single update command runs a series of commands from your fab file
def update(_rebuild=_rebuild, _update_svn=_update_svn):
    """Run everything to update the site (does restart)
    """

    _rebuild(_update_svn)

    fabcommon.site_status(domainname,
                          'updated to latest code and rebuilt, '
                          'please note that you may have to wait a few '
                          'minutes for zope to finish restarting')


def _rebuild(stopcallback=None, _restart=_restart):

    def f(stopcallback=stopcallback):
        if stopcallback is not None:
            stopcallback()
        fabcommon.run('./bin/buildout -v', basedir)

    _restart(f)


def update_svn(_update_svn=_update_svn):
    """Update svn for buildout (no restart)"""

    _update_svn()
    fabcommon.site_status(domainname,
                          'updated to latest code but the services were '
                          'NOT restarted')


						

ideas

  • Creating fab files using paster's interactive prompt
  • A library of Fabric utilities for Zope development. For example the download_datafs function should probably use repozo to be safe, or scripts that run benchmarks when the server code is updated
  • A mechanism to allow for rolling back a Fabric command should the Zeo clients fail to restart
Check out Fabric

I am not using WordPress

written by avanderlip, on Sep 1, 2008 10:47:00 PM.

The other night my local radio station had a piece on Christopher Alexander the author of A Pattern Language which is the foundation text for the software patterns movement. That particular book had been recommended to me before I started working with software so I was fascinated to see it resurface in this field. The interview itself was interesting, though my understanding of how software patterns relate to Alexander's work is different then what is presented in the broadcast. If you can get by the Yoda references, it is an interesting listen.

Why can't I be popular too?

A few weeks ago there was a discussion amongst my colleagues concerning a report on the open source CMS market. I had some reservations with the methodology; can you measure the market for a tool by search engine results? The report concluded that WordPress was currently the leading CMS in terms of market share and had this to say about Plone:

Plone shows strong performance in both fan sites and in books in print. A look at traffic patterns, mentions and queries, however, shows that the system's market share has been in a slide since mid-2007. Goodwill indicators are mixed and at this time we wonder whether Plone's window of opportunity is closing, at least in terms of market share. As we have no doubt about the Plone project's vitality, perhaps what we are seeing Plone moving away from a mass market offering and to a niche market position(?).

It is not news to the Plone community that we can always improve our marketing effort, nor is it news that Plone is not likely to become as popular as WordPress as they are quite different tools. What is frustrating about this report is how the definition of a CMS has been collapsed into simply posting content to the web plus tagging. Are blog tools content management systems? Is it enough to have through-the-web editing to qualify a tool as a CMS?

Quality Without A Name

I have been putting off blogging for a while, in part because I didn't want to use many of the tools out there, including WordPress, mostly because I am generally put off by PHP based-apps and want to be able to enjoy tinkering with what I use. I gave WordPress another shot, I downloaded the tarball and took a look around. I recognized some practices that gave me pause, display and logic code tightly bundled together, but I won't pass myself off as someone who can provide and deep expert analysis of the software. There is something else that the code lacks, something mentioned in the Alexander piece. WordPress lacked Quality Without a Name, the code didn't feel right, it was not a place I would want to spend time tinkering and exploring. Over time I may be able to better name the reasons why I choose Software X over Software Y. I suspect it has to do with my own intuition about the sweet spot for code, between limited or non existent abstraction and over abstraction. In working with Plone, I have had moments where I could recognize the quality, felt like I was working with quality code though I could not explain why technically, and moments where Plone seemed to lack the attention or work that resulted in the quality making itself apparent. Ward Cunningham explains that there was a period in history when "computers weren't any fun" and that this was the sentiment that drove some individuals to push for solving software problems with patterns, to make things better than they were. A big reason why work I with Plone is that many of the challenges that the Plone community is trying to solve may not make it immediately popular in terms of market buzz, but that Plone presents the opportunity for building something of lasting quality, something I see lacking in many software projects.

For now I am going to use TextPress, essentially a Python-based clone of Wordpress to keep my Python skills sharp and have side project to tinker with. Rocky Burt has put together an egg distribution and instructions for setting up a TexPress site, which for me is an initial endorsement of the software's quality. Off to tinker......