On Fri, 13 Oct 2006 18:44:35 +0200, Jan Bakuwel <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone wrote: > >> The return value of eomReceived is used to determine whether to signal to >> the SMTP client whether the message has been accepted. Regardless of your >> application logic, if you are taking responsibility for the message, you >> should return a successful result. If all of your processing is >> synchronous, >> then you simply need to return twisted.internet.defer.succeed(None) at the >> end of the function. If you have asynchronous processing to do (it does >> not >> appear as though you do), you will need to return a Deferred which only >> fires >> once that processing has been completed. > >There's still a bit of mystery in here for me... >I'll be taking responsibility for the message in my code... but perhaps >my code encounters a non resolvable error (such as disc full). In that >case I would like to be able to signal a failure instead of success. > >Would the following code do the job "properly"? > > def eomReceived(self): > # message is complete, store it > self.lines.append('') # add a trailing newline > messageData = '\n'.join(self.lines) > emailMessage = message_from_string(messageData) > try: > processEmail(emailMessage) > return defer.succeed(None) > except: > return defer.fail > #end eomReceived
Close. Return defer.fail() and it's basically correct. Sorry for the delayed response, python-list is high enough traffic that tracking down followups is kind of a hassle. You might want to move over to the Twisted list for further Twisted questions. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list