[PATCH 3 of 3 saem] [seda] Fix crash when profile has an originating agency not tight to an authority record

Sylvain Thénault sylvain.thenault at logilab.fr
Tue May 23 11:05:14 CEST 2017



Le 23/05/2017 à 10:11, Philippe Pepiot a écrit :
> On 05/19/2017 10:51 AM, Sylvain Thenault wrote:
>> # HG changeset patch
>> # User Sylvain Thénault <sylvain.thenault at logilab.fr>
>> # Date 1495116472 -7200
>> #      Thu May 18 16:07:52 2017 +0200
>> # Node ID 792626340c7a0c3d74208dddff9be1116f8dcbc4
>> # Parent  b619a152b407fb8352f7748c53a74df134ff85e4
>> # Available At http://hg.logilab.org/review/cubes/saem_ref
>> #              hg pull http://hg.logilab.org/review/cubes/saem_ref -r
>> 792626340c7a
>> [seda] Fix crash when profile has an originating agency not tight to
>> an authority record
>>
>> it used to fail with 'None has no attribute ark' because
>> monkey-patched method
>> doesn't handle the case where .agency is None (properly handled in
>> seda's
>> original implementation).
>>
>> Closes extranet #22071759
>>
>> diff --git a/cubicweb_saem_ref/entities/seda.py
>> b/cubicweb_saem_ref/entities/seda.py
>> --- a/cubicweb_saem_ref/entities/seda.py
>> +++ b/cubicweb_saem_ref/entities/seda.py
>> @@ -51,11 +51,11 @@ def xsd_archival_agreement(self, parent,
>>
>>
>>  # override agency_id to return ark instead of eid
>>  @monkeypatch(SEDA1XSDExport)
>>  def agency_id(self, agency):
>> -    return agency.agency.ark
>> +    return agency.agency.ark if agency.agency else None
>
> Applied first two patches.
>
> Could this be more clear with 'if agency.agency is not None' ?

fine

>
> Also the original implementation in cubicweb-seda suggest that agency
> itself could be None, maybe you should handle this here too ?

it actually can't be None, I will rather change this in the seda cube.

-- 
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org



More information about the saem-devel mailing list