[Twisted-Python] Woven View factories: defered rendering?

Michal Pasternak michal at pasternak.w.lub.pl
Wed Nov 19 22:20:41 EST 2003


I have a webpage, that is rendered via twisted.web.woven.page.Page class.

In one of it's wvfactory_ methods, I need to send an e-mail. I would also
like to check if sending of the e-mail was successful (eg. mailserver is
up, running, and reachable via network).

I thought about something like this:

  def wvfactory_render(self, req, node, model):
      # do some stuff 
      sendEMail().addCallbacks(self.emailOkay, self.emailFailure)
      return # what should I return here?
  def emailOkay(self, *args):
      # render "thank you, e-mail sent" message 
  def emailFailure(self, *args):
      # render "error" message
My questions:
   1) is it a good, Twisted Python way to do this? If not,
      a) what would be the correct one? 
      b) can you point me to some docs?
   2) if it is a good way:
      a) is it implemented? if yes:
      	 1) what should I return from wvfactory_render? 
	 2) what parameters would be passed to callbacks then?
      b) if not, do you think it would be worth implementing?
I have seen something similar like the thing I want to code in some example

       def render(...):
       	   [ launch some callbacks ] 
	   return server.NOT_DONE_YET
... but they were about Resource class, and I'm using Page here.


Michal Pasternak :: http://pasternak.w.lub.pl

More information about the Twisted-Python mailing list