def post(self): user_jid = self.request.body template_variables = [] path= os.path.join(os.path.dirname(__file__), 'templates/send_invite.html') if user_jid is None or user_jid == '': template_variables = {'success_code':'need to provide jid'} self.response.out.write(template.render(path,template_variables)) return logging.info('sending invite to: %s' % user_jid ) msg = "Welcome to [email protected]. You can track domains that are of your interest. \n\nFor more info type:\n/help" #TODO what about other protocols ? im = db.IM('xmpp',user_jid) xmpp.send_invite(user_jid) status_code = xmpp.send_message(im.address, msg) if status_code == xmpp.INVALID_JID or status_code == xmpp.OTHER_ERROR: template_variables = {'success_code':'error occured while sending xmpp message'} self.response.out.write(template.render(path,template_variables)) return chat_send = ( status_code != xmpp.NO_ERROR) if not chat_send: mail.send_mail(sender="Instapaper Firefox Addon<*****@*****.**>",to=user_jid,subject="Instaright over XMPP", body=msg) logging.info('mail has been sent instead of welcome message') logging.info('----%s----' % status_code) invite = IMInvite() invite.im=user_jid invite.subscribed = False invite.put() template_variables = {'success_code':'success'} self.response.out.write(template.render(path,template_variables))