[PATCH 2 of 2 seda] Make the component_unit predicate work with non seda entities

Denis Laxalde denis.laxalde at logilab.fr
Thu Sep 27 16:43:27 CEST 2018


Frank Bessou a écrit :
> # HG changeset patch
> # User Frank Bessou <frank.bessou at logilab.fr>
> # Date 1538055257 -7200
> #      Thu Sep 27 15:34:17 2018 +0200
> # Node ID 4b39cbc1d39e54f2f36c2618b0ad39e08139ce75
> # Parent  cc7900e2bfed295f42d2bea92f2f29882d5412ec
> # Available At http://hg.logilab.org/review/cubes/seda
> #              hg pull http://hg.logilab.org/review/cubes/seda -r 4b39cbc1d39e
> Make the component_unit predicate work with non seda entities
> 
> In the component_unit predicate, we handle the case where
> _seda_container_from_context returns None by returning 0.
> This can be the case when the predicate is called with a non seda
> entity.

Applied this one, thanks.

> diff --git a/cubicweb_seda/entities/__init__.py b/cubicweb_seda/entities/__init__.py
> --- a/cubicweb_seda/entities/__init__.py
> +++ b/cubicweb_seda/entities/__init__.py
> @@ -97,7 +97,9 @@ def component_unit(cls, req, rset=None, 
>      container root is not a SEDAArchiveTransfer but a SEDAArchiveUnit).
>      """
>      entity = _seda_container_from_context(rset, entity, **kwargs)
> -    return 1 if entity.cw_etype == 'SEDAArchiveUnit' else 0
> +    if entity and entity.cw_etype == 'SEDAArchiveUnit':
> +        return 1
> +    return 0
>  
>  
>  @objectify_predicate
> 



More information about the saem-devel mailing list