[PATCH seda] Provide a way to control the compound graph

Denis Laxalde denis.laxalde at logilab.fr
Thu Mar 30 16:26:04 CEST 2017


Sylvain Thenault a écrit :
> # HG changeset patch
> # User Sylvain Thénault <sylvain.thenault at logilab.fr>
> # Date 1490874781 -7200
> #      Thu Mar 30 13:53:01 2017 +0200
> # Node ID 1bb3b03fa6b64cf5e181736fae331609b7ac0493
> # Parent  a30217def173d82b9c0b438825761bc3f7f293d7
> Provide a way to control the compound graph
>
> useful for e.g. the saem_ref cube that introduces some entity types (Activity)
> which would be shared by different compound graph while we want it to be
> skipped.

I'm afraid I don't understand anything in this patch. What is the "way
to control the compound graph" that is apparently introduced here?

> diff --git a/cubicweb_seda/__init__.py b/cubicweb_seda/__init__.py
> --- a/cubicweb_seda/__init__.py
> +++ b/cubicweb_seda/__init__.py
> @@ -15,17 +15,26 @@
>  # with this program. If not, see <http://www.gnu.org/licenses/>.
>  """cubicweb-seda application package
>
>  Data Exchange Standard for Archival
>  """
> +from functools import partial
>
> -from cubicweb_compound import structure_def, skip_rtypes_set, CompositeGraph
> +from cubicweb_compound import skip_rtypes_set, CompositeGraph
> +
> +# data structure allowing control of the compound graph:
> +#
> +# SEDAArchiveTransferGraph.keywords['skipetypes'].append('SomeEtype')
> +# SEDAArchiveTransferGraph.keywords['skiprtypes'].append('some_rtype')
> +SEDAArchiveTransferGraph = partial(CompositeGraph, skipetypes=[], skiprtypes=[])
>

What is the meaning of these comments? In particular where does the
"keywords" attribute come from?

>  def seda_profile_container_def(schema):
> -    """Define container for SEDAProfile"""
> -    return structure_def(schema, 'SEDAArchiveTransfer').items()
> +    """Define container for SEDAArchiveTransfer, as a list of (etype, parent_rdefs)."""
> +    graph = SEDAArchiveTransferGraph(schema)
> +    return [(child, set(relinfo))
> +            for child, relinfo in graph.parent_structure('SEDAArchiveTransfer').items()]
>

How is this related to the topic of the patch?

>  def iter_external_rdefs(eschema, skip_rtypes=skip_rtypes_set(['container'])):
>      """Return an iterator on (rdef, role) of external relations from entity schema (i.e.
>      non-composite relations).
> @@ -42,11 +51,11 @@ def iter_external_rdefs(eschema, skip_rt
>
>  def iter_all_rdefs(schema, container_etype):
>      """Return an iterator on (rdef, role) of all relations of the compound graph starting from the
>      given entity type, both internal (composite) and external (non-composite).
>      """
> -    graph = CompositeGraph(schema)
> +    graph = SEDAArchiveTransferGraph(schema)
>      stack = [container_etype]
>      visited = set(stack)
>      while stack:
>          etype = stack.pop()
>          for (rtype, role), targets in graph.child_relations(etype):
>



More information about the saem-devel mailing list