adhocracy_core.graph package¶
Set/Get Resource References / versions graph (DAG) helpers.
-
class
Graph(context)[source]¶ Bases:
persistent.PersistentUtility to work with versions/references.
This implementation depends on the
substanced.objectmap.Objectmapservice.Initialize self.
-
get_reftypes(base_isheet=<InterfaceClass adhocracy_core.interfaces.ISheet>, base_reftype=<SheetReferenceClass adhocracy_core.interfaces.SheetReference>) → collections.abc.Iterator[source]¶ Collect all used SheetReferenceTypes.
Return type: Parameters: - base_reftype – Skip types that are not subclasses of this.
- base_isheet – Skip types with a source isheet that is not a subclass of this.
Returns: Generator of
adhocracy_core.graph.SheetReftype
-
set_references(source, targets: collections.abc.Iterable, reftype: <SheetReferenceClass adhocracy_core.interfaces.SheetReference>, registry: pyramid.registry.Registry=None, send_event=True)[source]¶ Set references of this source.
Parameters: - targets (
Iterable) – the reference targets, for Sequences the order is preserved. - reftype – the reftype mapping to one isheet field.
- registry (
Registry) – pyramid registry to notify referenced resources. Default value is None to ease testing. - send_event (
bool) – send events to notify referenced resources
- targets (
-
get_references(source, base_isheet=<InterfaceClass adhocracy_core.interfaces.ISheet>, base_reftype=<SheetReferenceClass adhocracy_core.interfaces.SheetReference>) → collections.abc.Iterator[source]¶ Get generator of
Referencewith this source.
-
get_back_references(target, base_isheet=<InterfaceClass adhocracy_core.interfaces.ISheet>, base_reftype=<SheetReferenceClass adhocracy_core.interfaces.SheetReference>) → collections.abc.Iterator[source]¶ Get generator of
Referencewith this target.
-
get_back_reference_sources(resource, reftype=<SheetReferenceClass adhocracy_core.interfaces.SheetReference>) → collections.abc.Iterable[source]¶ Get generator of the sources of backreferences.
Return type: Parameters: - resource – the resource whose backreferences we want
- reftype – the type of backreferences we want
Returns: a generator of reference sources (sheets referring to the resource)
-
set_references_for_isheet(source, isheet: <InterfaceClass adhocracy_core.interfaces.ISheet>, references: dict, registry: pyramid.registry.Registry, send_event=True)[source]¶ Set references of this source for one isheet.
Parameters: - references (
dict) – dictionary with the following content: key - isheet field name value - reference targets - registry (
Registry) – Pyramid Registry withadhocracy_core.content.ResourceContentRegistryattribute named content.
- references (
-
get_references_for_isheet(source, isheet: <InterfaceClass adhocracy_core.interfaces.ISheet>) → dict[source]¶ Get references of this source for one isheet only.
Returns: dictionary with the following content: key - isheet field name value - reference targets References from subtypes of isheet are also listed. Fields without existing references are ignored.
-
get_back_references_for_isheet(target, isheet: <InterfaceClass adhocracy_core.interfaces.ISheet>) → dict[source]¶ Get references that point to this target for one isheet only.
- : return: dictionary with the following content:
key - isheet field name value - references sources
References from subtypes of isheet are also listed. Fields without existing references are ignored.
-
is_in_subtree(descendant, ancestors: collections.abc.Iterable) → bool[source]¶ Check whether a resource is in a subtree below other resources.
Return type: boolParameters: - descendant – the candidate descendant
- ancestors (
Iterable) – the candidate ancestors
Returns: True if there exists a relation from one of the ancestors to descendant that does NOT include any ‘follows’ links. For example, descendant might be an element of an element (of an element...) of an ancestor. Also if descendant and one of the ancestors are the same node.
False otherwise.
-