[Twisted-Python] deferred
Thomas Weholt
2002 at weholt.org
Tue Dec 2 17:54:48 EST 2003
Your error has nothing to do with deferred. The error is coming from MySQL and it probably means your trying to insert duplicate values in a primary key field or some other field which must be uniqe in your table.
Thomas
----- Original Message -----
From: vicky lupien
To: twisted-python at twistedmatrix.com
Sent: Tuesday, December 02, 2003 10:56 PM
Subject: [Twisted-Python] deferred
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 = str(os.sep).join([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:
<html>
<head>
</head>
<body>
<br />
<br />
ALLO
<div model="theDeferred" view="message">
</div>
</body>
</html>
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?
vicky
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20031202/b7405378/attachment.htm
More information about the Twisted-Python
mailing list