def operation_finished(exception, retval): msg = None if retval: msg = "Status Deleted<br> Successfully" else: msg = "Unknow error.<br> Please try again" if exception is not None: if isinstance(exception, TwitterError): msg = "Unable to connect<br> to server" + \ "Check your connection<br> and try again." elif isinstance(exception, AuthError): msg = "Authentication error" else: msg = "An unknown error<br> has occured<br> " + \ str(exception.message) log.error(exception) self.view.hide() self.view = ResultMessageView(self.parent.last_panel, self.model.title, None, msg) self.view.callback_ok_clicked = self.close self.view.show()
def __init__(self, model, canvas, parent): ModalController.__init__(self, model, canvas, parent) self.model = model self.parent = parent self.view = SetReplyView(model.user_id, parent.last_panel, model.title, None) self.view.callback_ok_clicked = self._on_ok_clicked self.view.callback_cancel_clicked = self.close self.view.callback_escape = self.close self.view.show()
def __init__(self, model, canvas, parent): ModalController.__init__(self, model, canvas, parent) self.model = model self.parent = parent label = 'Are you sure you <br>want to delete this <br>status?' self.view = ConfirmDialogView(label, parent.last_panel, model.title, None) self.view.callback_yes_clicked = self._on_yes_clicked self.view.callback_no_clicked = self.close self.view.callback_escape = self.close self.view.show()
class TwitterReplyOptionsController(ModalController): terra_type = "Controller/Options/Folder/Apps/Twitter/Message/Reply" def __init__(self, model, canvas, parent): ModalController.__init__(self, model, canvas, parent) self.model = model self.parent = parent self.view = SetReplyView(model.user_id, parent.last_panel, model.title, None) self.view.callback_ok_clicked = self._on_ok_clicked self.view.callback_cancel_clicked = self.close self.view.callback_escape = self.close self.view.show() def close(self): def cb(*ignored): self.back() self.parent.back() self.view.hide(end_callback=cb) def _on_ok_clicked(self, reply): def do_operation(): self.reply = reply self.view.hide() self.view = WaitMessageView(self.parent.last_panel, self.model.title, None, 'Operation in progress<br>Please Wait') self.view.show() return self.model.reply(reply) def operation_finished(exception, retval): msg = None if retval: msg = "Reply sent<br> Successfully" else: msg = "Unknow error.<br> Please try again" if exception is not None: if isinstance(exception, TwitterError): msg = "Unable to connect<br> to server" + \ "Check your connection<br> and try again" elif isinstance(exception, AuthError): msg = "Authentication error" else: msg = "An unknown error<br> has occured<br>" + \ str(exception.message) log.error(exception) self.view.hide() self.view = ResultMessageView(self.parent.last_panel, self.model.title, None, msg) self.view.callback_ok_clicked = self.close self.view.show() ThreadedFunction(operation_finished, do_operation).start() def delete(self): self.view.delete() self.view = None self.model = None
def do_operation(): self.view.hide() self.view = WaitMessageView(self.parent.last_panel, self.model.title, None, 'Operation in progress<br>Please Wait') self.view.show() return self.model.deleteStatus()