def actionSuccess(self, req): resp = NetworkService.decode(req) logging.debug("actionSuccess: %r", resp) ''' severity cases: NotSet = 0 InvalidatesOther = 1 <-- relevant Empty = 2 Invalid = 3 <-- relevant ''' if "action" in resp and resp["action"].endswith("Success"): # form approved: Let's store the new skeleton values and fire the success event self.skel = resp["values"] self.formSuccessEvent.fire(self) else: #form rejected self.errors = resp["errors"] for error in self.errors: if error["fieldPath"] in self.bones: boneField = self.bones[ error["fieldPath"]] # todo dependency errors if (error["severity"]%2 == 0 and boneField["required"]) or\ (error["severity"]%2 == 1): #invalid boneField.setInvalid() else: boneField.setValid() self.createFormErrorMessage()
def onUploadUrlAvailable(self, req): """ Internal callback - the actual upload url (retrieved by calling /file/getUploadURL) is known. """ params = NetworkService.decode(req)["values"] formData = html5.jseval("new FormData();") #if self.context: # for k, v in self.context.items(): # formData.append(k, v) #if req.node and str(req.node) != "null": # formData.append("node", req.node) for key, value in params["params"].items(): if key == "key": self.targetKey = value[:-16] # Truncate source/file.dat fileName = req.file.name value = value.replace("file.dat", fileName) formData.append(key, value) formData.append("file", req.file) self.xhr = html5.jseval("new XMLHttpRequest()") self.xhr.open("POST", params["url"]) self.xhr.onload = self.onLoad self.xhr.upload.onprogress = self.onProgress self.xhr.send(formData)
def actionSuccess(self, req): resp = NetworkService.decode(req) logging.debug("actionSuccess: %r", resp) ''' severity cases: NotSet = 0 InvalidatesOther = 1 <-- relevant Empty = 2 Invalid = 3 <-- relevant ''' if "action" in resp and resp["action"].endswith("Success"): # form approved: Let's store the new skeleton values and fire the success event self.skel = resp["values"] self.formSuccessEvent.fire(self) else: #form rejected self.errors = resp["errors"] self.handleErrors()
def onSkeyAvailable(self, req): """ Internal callback - the Security-Key is known. # Only for core 2.x needed """ formData = html5.jseval("new FormData();") formData.append("file", req.file) if self.context: for k, v in self.context.items(): formData.append(k, v) if req.node and str(req.node) != "null": formData.append("node", req.node) formData.append("skey", NetworkService.decode(req)) self.xhr = html5.jseval("new XMLHttpRequest()") self.xhr.open("POST", req.destUrl) self.xhr.onload = self.onLoad self.xhr.upload.onprogress = self.onProgress self.xhr.send(formData)
def onUploadAdded(self, req): self.responseValue = NetworkService.decode(req) DeferredCall(self.onSuccess, _delay=1000)