betty.privacy package

Submodules

Module contents

The Privacy API.

class betty.privacy.HasPrivacy[source]

Bases: LinkedDataDumpableJsonLdObject

A resource that has privacy.

__init__(*args: Any, privacy: Privacy | None = None, public: bool | None = None, private: bool | None = None, **kwargs: Any)[source]
async dump_linked_data(project: Project) DumpMapping[Dump][source]

Dump this instance to JSON-LD.

async classmethod linked_data_schema(project: Project) JsonLdObject[source]

Define the JSON Schema for betty.json.linked_data.LinkedDataDumpable.dump_linked_data().

property own_privacy: Privacy

The resource’s own privacy.

This returns the value that was set for betty.privacy.HasPrivacy.privacy and ignores computed privacies.

For access control and permissions checking, use betty.privacy.HasPrivacy.privacy.

property privacy: Privacy

The resource’s privacy.

property private: bool

Whether this resource is private.

property public: bool

Whether this resource is public.

class betty.privacy.Privacy[source]

Bases: Enum

The available privacy modes.

PRIVATE = 2

The resource is explicitly made private.

PUBLIC = 1

The resource is explicitly made public.

UNDETERMINED = 3

The resource has no explicit privacy. This means that:

  • it may be changed at will

  • when checking access, UNDETERMINED evaluates to PUBLIC.

class betty.privacy.PrivacySchema[source]

Bases: Boolean

A JSON Schema for privacy.

__init__()[source]
betty.privacy.is_private(target: Any) bool[source]

Check if the given target is private.

betty.privacy.is_public(target: Any) bool[source]

Check if the given target is public.

betty.privacy.merge_privacies(*privacies: Privacy | HasPrivacy | None) Privacy[source]

Merge multiple privacies into one.

betty.privacy.resolve_privacy(privacy: Privacy | HasPrivacy | None) Privacy[source]

Resolve the privacy of a value.