Revision 2fd11a01 snf-quotaholder-app/quotaholder_django/quotaholder_app/callpoint.py

b/snf-quotaholder-app/quotaholder_django/quotaholder_app/callpoint.py
49 49
                     now,
50 50
                     db_get_entity, db_get_holding, db_get_policy,
51 51
                     db_get_commission, db_filter_provision, db_get_callserial)
52
import json
53 52

  
54 53
class QuotaholderDjangoDBCallpoint(Callpoint):
55 54

  
......
570 569
            raise ReturnButFail(rejected)
571 570

  
572 571
        if serial is not None and clientkey is not None:
573
            data = json.dumps(all_pairs)
574
            CallSerial.objects.create(serial=serial,
575
                                      clientkey=clientkey,
576
                                      data=data)
572
            CallSerial.objects.create(serial=serial, clientkey=clientkey)
577 573
        return rejected
578 574

  
579
    def ack_serial(self, context={}, clientkey=None, serial=None,
580
                   fetch_args=False):
575
    def ack_serials(self, context={}, clientkey=None, serials=()):
576
        if clientkey is None:
577
            return
578

  
579
        for serial in serials:
580
            try:
581
                c = db_get_callserial(clientkey=clientkey,
582
                                      serial=serial,
583
                                      for_update=True)
584
                c.delete()
585
            except CallSerial.DoesNotExist:
586
                pass
587
        return
588

  
589
    def query_serials(self, context={}, clientkey=None, serials=()):
581 590
        result = []
582
        try:
583
            cs = db_get_callserial(clientkey=clientkey,
584
                                   serial=serial,
585
                                   for_update=True)
586
        except CallSerial.DoesNotExist:
591
        append = result.append
592

  
593
        if clientkey is None:
587 594
            return result
588 595

  
589
        if fetch_args:
590
            result = json.loads(cs.data)
596
        if not serials:
597
            cs = CallSerial.objects.filter(clientkey=clientkey)
598
            return [c.serial for c in cs]
599

  
600
        for serial in serials:
601
            try:
602
                db_get_callserial(clientkey=clientkey, serial=serial)
603
                append(serial)
604
            except CallSerial.DoesNotExist:
605
                pass
591 606

  
592
        cs.delete()
593 607
        return result
594 608

  
595 609
    def issue_commission(self,  context     =   {},

Also available in: Unified diff