[Twisted-Python] deferred

vicky lupien vlupien at drummonddesigns.com
Tue Dec 2 16:56:12 EST 2003

I have a problem with deferred.  I have a wmfactory that return the
results of a sql query but sometimes it occurs that the result is an
sql-exception error because it's an insert query and sometimes the data
are already in the database. When this kind of error occurs, the page is
not render and I got an error.
Here's what I talking about:
class MessagePage(pages.BasePage):
    templateDirectory =
    templateFile = "message.html"
    def initialize(self, theDeferred=None):
         # theDeferred is the results of an sql query of an other page
but at the stage of deferred
        self.theDeferred = theDeferred
    def wmfactory_theDeferred(self, request):
        return self.theDeferred   #here's where the error occurs.  When
the sql queries is ok everything is fine but when it's an sql exception
it breaks
    def wvupdate_message(self, request, widget, data):
        print data  # I don't want to just print the data
(self.deferred) but it's a test to see what's the problem
My template:
                        <br />
                        <br />
                        <div model="theDeferred" view="message">
The error I got when it's an sql exception:
_mysql_exceptions.IntegrityError: (1062, "Duplicate entry '12345' for
key 2")
how can I avoid this error?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20031202/f60e2d1c/attachment.htm 

More information about the Twisted-Python mailing list