Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 85003184

Přidáno uživatelem Michal Seják před téměř 4 roky(ů)

Re #8572 - Added a `get_all_descendants_of(id)` (meaning descendants in general) method to the CertificateRepository.

Zobrazit rozdíly:

src/dao/certificate_repository.py
389 389

  
390 390
        return certificates
391 391

  
392
    def get_all_descendants_of(self, certificate_id: int):
393
        """
394
        Get a list of all certificates C such that the certificate identified by "certificate_id" belongs to a trust chain
395
        between C and its root certificate authority (i.e. is an ancestor of C).
396
        :param certificate_id: target certificate ID
397
        :return: list of all descendants
398
        """
399
        def dfs(children_of, this, collection: list):
400
            for child in children_of(this.certificate_id):
401
                dfs(children_of, child, collection)
402
            collection.append(this)
403

  
404
        subtree_root = self.read(certificate_id)
405
        if subtree_root is None:
406
            return None
407

  
408
        all_certs = []
409
        dfs(self.get_all_issued_by, subtree_root, all_certs)
410
        return all_certs
411

  
392 412
    def get_next_id(self) -> int:
393 413
        """
394 414
        Get identifier of the next certificate that will be inserted into the database

Také k dispozici: Unified diff