[Twisted-Python] twistd and SqlObject

Graham Stratton gns24 at sphinx.mythic-beasts.com
Tue Aug 23 08:17:40 EDT 2005

I'm sure the answer to this question should be obvious, but I can't find

I've written a twisted server which recieves a request, looks up the
requested data in its cache, and returns the data.  It accesses its
database via SQLObject - the database is small, so I don't care that it
blocks.  Twisted has certainly made this very simple.

I now want to run that same process using twistd (-noy), but SqlObject
gives the error
Failed to load application: 'NoneType' object has no attribute

on the last line of the listing below, which works fine when run normally.

I guess I'm being very naive about the way in which twistd works, but I
can't find any comprehensive documentation saying what it does.

Thanks for any pointers,


import _mysql_exceptions
from elementtree.ElementTree import Element, SubElement, ElementTree,
from twisted.internet import reactor
from twisted.web import server
from twisted.web.resource import Resource
from twisted.web.client import getPage
from cStringIO import StringIO
import sqlobject
import datetime
now = datetime.datetime.now

cacheDurationDays = 90
__connection__ = sqlobject.MySQLConnection(host='localhost',
                                           user='root', passwd='chubchub')

class CachedDomain(sqlobject.SQLObject):
    """The table that the data is cached in"""
    domain = sqlobject.StringCol(length=80)
    alexa3monthtraffic = sqlobject.FloatCol()
    lastUpdate = sqlobject.DateTimeCol()
    domainIndex = sqlobject.DatabaseIndex({'column':domain, 'length':8})


More information about the Twisted-Python mailing list