(self, result, signal=True, verify=True)
由字典更新数据
由字典更新数据
由字典更新数据
def update(self, result, signal=True, verify=True):
        """由字典更新数据"""
        verify and self.verify(result)
        updated = False
        for field in self.ALLOW_UPDATES:
            data = result.get(field)
            if not getattr(self, field) and data:
                setattr(self, field, data)
                updated = True
        updated and self.save()

        try:
            self.result.update(result, signal=signal, verify=False)
        except AttributeError:
            from . import UnifiedOrderResult
            transaction_id = result.get("transaction_id") or None
            obj = UnifiedOrderResult(order=self,
                                     transaction_id=transaction_id)
            obj.update(result, signal=signal, verify=False)
def update ( self , result , signal = True , verify = True ) : verify and self . verify ( result ) updated = False for field in self . ALLOW_UPDATES : data = result . get ( field ) if not getattr ( self , field ) and data : setattr ( self , field , data ) updated = True updated and self . save ( ) try : self . result . update ( result , signal = signal , verify = False ) except AttributeError : from . import UnifiedOrderResult transaction_id = result . get ( "transaction_id" ) or None obj = UnifiedOrderResult ( order = self , transaction_id = transaction_id ) obj . update ( result , signal = signal , verify = False )