backend.globaleaks.handlers.public

Module Contents

Classes

PublicResource Handler responsible of serving the public API

Functions

db_get_triggers_by_type(session, type, object_id) Transaction for retrieving field triggers associated to an object given the type of trigger
db_prepare_contexts_serialization(session, contexts) Transaction to prepare and optimize context serialization
db_prepare_receivers_serialization(session, receivers) Transaction to prepare and optimize receiver serialization
db_prepare_fields_serialization(session, fields) Transaction to prepare and optimize fields serialization
db_serialize_node(session, tid, language) Serialize the public node configuration.
serialize_context(session, context, language, data=None) Serialize a context.
serialize_field_option(option, language) Serialize a field option.
serialize_field_attr(attr, language) Serialize a field attribute.
serialize_field(session, tid, field, language, data=None, serialize_templates=True) Serialize a field
serialize_step(session, tid, step, language, serialize_templates=True) Serialize a step.
serialize_questionnaire(session, tid, questionnaire, language, serialize_templates=True) Serialize a questionnaire.
serialize_receiver(session, user, language, data=None) Serialize a receiver.
db_get_questionnaires(session, tid, language) Transaction that serialize the list of public questionnaires
db_get_contexts(session, tid, language) Transaction that serialize the list of public contexts
db_get_receivers(session, tid, language) Transaction that serialize the list of public receivers
get_public_resources(session, tid, language) Transaction that compose the public API
backend.globaleaks.handlers.public.special_fields = ['whistleblower_identity'][source]
backend.globaleaks.handlers.public.trigger_map[source]
backend.globaleaks.handlers.public.db_get_triggers_by_type(session, type, object_id)[source]

Transaction for retrieving field triggers associated to an object given the type of trigger

Parameters:
  • session – An ORM session
  • type – The type of trigger involved in the lookup
  • object_id – The object on which performing the lookup
Returns:

A list of triggers descriptors

backend.globaleaks.handlers.public.db_prepare_contexts_serialization(session, contexts)[source]

Transaction to prepare and optimize context serialization

Parameters:
  • session – An ORM session
  • contexts – The list of context for which preparing the serialization
Returns:

The set of retrieved objects necessary for optimizing the serialization

backend.globaleaks.handlers.public.db_prepare_receivers_serialization(session, receivers)[source]

Transaction to prepare and optimize receiver serialization

Parameters:
  • session – An ORM session
  • receivers – The list of receivers for which preparing the serialization
Returns:

The set of retrieved objects necessary for optimizing the serialization

backend.globaleaks.handlers.public.db_prepare_fields_serialization(session, fields)[source]

Transaction to prepare and optimize fields serialization

Parameters:
  • session – An ORM session
  • fields – The list of receivers for which preparing the serialization
Returns:

The set of retrieved objects necessary for optimizing the serialization

backend.globaleaks.handlers.public.db_serialize_node(session, tid, language)[source]

Serialize the public node configuration.

Parameters:
  • session – An ORM session
  • tid – A tenant ID
  • language – The language to be used during serialization
Returns:

The serialization of the public node configuration

backend.globaleaks.handlers.public.serialize_context(session, context, language, data=None)[source]

Serialize a context.

Parameters:
  • session – An ORM session
  • context – The context to be serialized
  • language – The language to be used during serialization
  • data – The dictionary of prefetched resources
backend.globaleaks.handlers.public.serialize_field_option(option, language)[source]

Serialize a field option.

Parameters:
  • option – The option to be serialized
  • language – The language to be used during serialization
Returns:

The serialized resource

backend.globaleaks.handlers.public.serialize_field_attr(attr, language)[source]

Serialize a field attribute.

Parameters:
  • attr – The option to be serialized
  • language – The language to be used during serialization
Returns:

The serialized resource

backend.globaleaks.handlers.public.serialize_field(session, tid, field, language, data=None, serialize_templates=True)[source]

Serialize a field

Parameters:
  • session – An ORM session
  • tid – A tenant ID
  • field – The option to be serialized
  • language – The language to be used during serialization
  • data – The dictionary of prefetched resources
  • serialize_templates – A boolean to require template serialization
Returns:

The serialized resource

backend.globaleaks.handlers.public.serialize_step(session, tid, step, language, serialize_templates=True)[source]

Serialize a step.

Parameters:
  • session – An ORM session
  • tid – A tenant ID
  • step – The option to be serialized
  • language – The language to be used during serialization
  • serialize_templates – A boolean to require template serialization
Returns:

The serialized resource

backend.globaleaks.handlers.public.serialize_questionnaire(session, tid, questionnaire, language, serialize_templates=True)[source]

Serialize a questionnaire.

Parameters:
  • session – An ORM session
  • tid – A tenant ID
  • questionnaire – A questionnaire model
  • language – The language to be used during serialization
  • serialize_templates – A boolean to require template serialization
Returns:

The serialized resource

backend.globaleaks.handlers.public.serialize_receiver(session, user, language, data=None)[source]

Serialize a receiver.

Parameters:
  • session – An ORM session
  • user – The model to be serialized
  • language – The language to be used during serialization
  • data – The dictionary of prefetched resources
Returns:

The serialized resource

backend.globaleaks.handlers.public.db_get_questionnaires(session, tid, language)[source]

Transaction that serialize the list of public questionnaires

Parameters:
  • session – An ORM session
  • tid – The tenant ID
  • language – The language to be used for the serialization
Returns:

A list of contexts descriptors

backend.globaleaks.handlers.public.db_get_contexts(session, tid, language)[source]

Transaction that serialize the list of public contexts

Parameters:
  • session – An ORM session
  • tid – The tenant ID
  • language – The language to be used for the serialization
Returns:

A list of contexts descriptors

backend.globaleaks.handlers.public.db_get_receivers(session, tid, language)[source]

Transaction that serialize the list of public receivers

Parameters:
  • session – An ORM session
  • tid – The tenant ID
  • language – The language to be used for the serialization
Returns:

A list of receivers descriptors

backend.globaleaks.handlers.public.get_public_resources(session, tid, language)[source]

Transaction that compose the public API

Parameters:
  • session – An ORM session
  • tid – The tenant ID
  • language – The language to be used for serialization
Returns:

The public API descriptor

class backend.globaleaks.handlers.public.PublicResource[source]

Bases: globaleaks.handlers.base.BaseHandler

Handler responsible of serving the public API

check_roles = none[source]
cache_resource = True[source]
get(self)[source]

Get the public resource