shoop.notify package

Submodules

shoop.notify.base module

class shoop.notify.base.BaseMetaclass[source]

Bases: type

class shoop.notify.base.Variable(name, type=<class 'shoop.notify.typology.Type'>, required=True, help_text='')[source]

Bases: object

get_matching_types(variable_dict)[source]
class shoop.notify.base.Binding(name, type=<class 'shoop.notify.typology.Type'>, required=False, help_text='', constant_use=<ConstantUse.VARIABLE_ONLY: 1>, default=None)[source]

Bases: shoop.notify.base.Variable

accepts_any_type
allow_constant
allow_variable
get_value(context, bind_data)[source]
class shoop.notify.base.TemplatedBinding(*args, **kwargs)[source]

Bases: shoop.notify.base.Binding

get_value(context, bind_data)[source]
class shoop.notify.base.Base[source]

Bases: object

identifier = None
name = None
description = None
variables = {}
bindings = {}
provide_category = None
classmethod class_for_identifier(identifier)[source]
class shoop.notify.base.Event(**variable_values)[source]

Bases: shoop.notify.base.Base

provide_category = 'notify_event'
identifier = None
log_target_variable = None

The name of the variable to be used as the log target for this event.

The target variable must have an add_log_entry method.

log_target
load_variables(variable_values)[source]
run()[source]
bindings = {}
variables = {}
class shoop.notify.base.ScriptItem(data, validate=True)[source]

Bases: shoop.notify.base.Base

provide_category = None
verify_bindings()[source]
get_value(context, binding_name)[source]

Get the actual value of a binding from the given script context.

Parameters:
Returns:

The variable value

get_values(context)[source]

Get all binding values in a dict.

Parameters:context (shoop.notify.script.Context) – Script Context
Returns:Dict of binding name -> value
Return type:dict[name, value]
classmethod unserialize(data, validate=True)[source]
serialize()[source]
classmethod get_ui_info_map()[source]
bindings = {}
identifier = 'script_item'
name = 'Script Item'
variables = {}
class shoop.notify.base.Condition(data, validate=True)[source]

Bases: shoop.notify.base.ScriptItem

provide_category = 'notify_condition'
test(context)[source]
bindings = {}
identifier = 'condition'
name = 'Condition'
variables = {}
class shoop.notify.base.Action(data, validate=True)[source]

Bases: shoop.notify.base.ScriptItem

provide_category = 'notify_action'
template_use = <TemplateUse.NONE: 0>
template_fields = {}
execute(context)[source]
Parameters:context (shoop.notify.script.Context) – Script Context
get_template(context)[source]

Get this action’s template instance, bound in the context.

Return type:shoop.notify.template.Template
bindings = {}
get_template_values(context, language_preferences=())[source]

Render this Action’s template with data from the given context.

Parameters:
  • context (shoop.notify.script.Context) – Script Context
  • language_preferences (list[str]) – Language preference list. The first language in the template to have values for all fields will be used. Has no effect for UNILINGUAL template_use.
Returns:

Dict of field name -> rendered template text.

Return type:

dict[str, str]|None

identifier = 'action'
name = 'Action'
variables = {}

shoop.notify.enums module

class shoop.notify.enums.TemplateUse[source]

Bases: enumfields.enums.Enum

An enumeration.

NONE = <TemplateUse.NONE: 0>
UNILINGUAL = <TemplateUse.UNILINGUAL: 1>
MULTILINGUAL = <TemplateUse.MULTILINGUAL: 2>
class shoop.notify.enums.ConstantUse[source]

Bases: enumfields.enums.Enum

An enumeration.

VARIABLE_ONLY = <ConstantUse.VARIABLE_ONLY: 1>
CONSTANT_ONLY = <ConstantUse.CONSTANT_ONLY: 2>
VARIABLE_OR_CONSTANT = <ConstantUse.VARIABLE_OR_CONSTANT: 3>
class shoop.notify.enums.StepNext[source]

Bases: enumfields.enums.Enum

An enumeration.

CONTINUE = <StepNext.CONTINUE: 'continue'>
STOP = <StepNext.STOP: 'stop'>
class shoop.notify.enums.StepConditionOperator[source]

Bases: enumfields.enums.Enum

An enumeration.

ALL = <StepConditionOperator.ALL: 'all'>
ANY = <StepConditionOperator.ANY: 'any'>
NONE = <StepConditionOperator.NONE: 'none'>
class shoop.notify.enums.RecipientType[source]

Bases: enumfields.enums.Enum

An enumeration.

ADMINS = <RecipientType.ADMINS: 1>
SPECIFIC_USER = <RecipientType.SPECIFIC_USER: 2>
class shoop.notify.enums.Priority[source]

Bases: enumfields.enums.Enum

An enumeration.

LOW = <Priority.LOW: 1>
NORMAL = <Priority.NORMAL: 2>
HIGH = <Priority.HIGH: 3>
CRITICAL = <Priority.CRITICAL: 4>

shoop.notify.runner module

shoop.notify.runner.run_event(event)[source]

shoop.notify.script module

shoop.notify.script.none(conditions)[source]
class shoop.notify.script.Step(conditions=(), actions=(), next=<StepNext.CONTINUE: 'continue'>, cond_op=<StepConditionOperator.ALL: 'all'>, enabled=True)[source]

Bases: object

execute(context)[source]
serialize()[source]
classmethod unserialize(step_data)[source]
enabled
class shoop.notify.script.Context(variables=None)[source]

Bases: object

classmethod from_variables(**variables)[source]

Create Context from variables.

Return type:shoop.notify.script.Context
classmethod from_event(event)[source]

Create Context from event.

Return type:shoop.notify.script.Context
get(name, default=None)[source]
set(name, value)[source]
get_variables()[source]
log(level, msg, *args, **kwargs)[source]

Log a message with the context’s logger (not the log target). This may be an useful debugging tool.

The parameters are the same as for logging.Logger.log().

add_log_entry_on_log_target(message, identifier, **kwargs)[source]

Add a log entry on the context’s log target.

The kwargs are passed to the target’s add_log_entry method.

If no log target exists or if it has no add_log_entry method, this method does nothing.

Parameters:
  • message (str) – The message text.
  • identifier (str) – The message identifier. Unlike with add_log_entry, this is required.
  • kwargs (dict) – Other kwargs to pass to add_log_entry
log_entry_queryset

shoop.notify.settings module

shoop.notify.template module

exception shoop.notify.template.NoLanguageMatches[source]

Bases: Exception

shoop.notify.template.render_in_context(context, template_text, html_intent=False)[source]

Render the given Jinja2 template text in the script context.

Parameters:
  • context (shoop.notify.script.Context) – Script context.
  • template_text (str) – Jinja2 template text.
  • html_intent (bool) – Is the template text intended for HTML output? This currently turns on autoescaping.
Returns:

Rendered template text

Return type:

str

Raises:

Whatever Jinja2 might happen to raise

class shoop.notify.template.Template(context, data)[source]

Bases: object

Parameters:
has_language(language, fields)[source]
render(language, fields)[source]

Render this template in the given language, returning the given fields.

Parameters:
  • language (str) – Language code (ISO 639-1 or ISO 639-2)
  • fields (list[str]) – Desired fields to render.
Returns:

Dict of field -> rendered content.

Return type:

dict[str, str]

render_first_match(language_preferences, fields)[source]

shoop.notify.typology module

class shoop.notify.typology.Type[source]

Bases: object

name = None
identifier = None
get_field(**kwargs)[source]

Get a Django form field for this type.

The kwargs are passed directly to the field constructor.

Parameters:kwargs (dict) – Kwargs for field constructor
Returns:Form field
Return type:django.forms.Field
unserialize(value)[source]
validate(value)[source]
is_coercible_from(other_type)[source]
class shoop.notify.typology.Boolean[source]

Bases: shoop.notify.typology.Type

name = <django.utils.functional.lazy.<locals>.__proxy__ object>
identifier = 'boolean'
class shoop.notify.typology.Integer[source]

Bases: shoop.notify.typology._Number

name = <django.utils.functional.lazy.<locals>.__proxy__ object>
identifier = 'integer'
get_field(**kwargs)[source]
class shoop.notify.typology.Decimal[source]

Bases: shoop.notify.typology._Number

name = <django.utils.functional.lazy.<locals>.__proxy__ object>
identifier = 'decimal'
get_field(**kwargs)[source]
class shoop.notify.typology.Text[source]

Bases: shoop.notify.typology._String

name = <django.utils.functional.lazy.<locals>.__proxy__ object>
identifier = 'text'
is_coercible_from(other_type)[source]
class shoop.notify.typology.Language[source]

Bases: shoop.notify.typology._String

name = <django.utils.functional.lazy.<locals>.__proxy__ object>
identifier = 'language'
class shoop.notify.typology.Email[source]

Bases: shoop.notify.typology._String

name = <django.utils.functional.lazy.<locals>.__proxy__ object>
identifier = 'email'
get_field(**kwargs)[source]
class shoop.notify.typology.URL[source]

Bases: shoop.notify.typology._String

name = <django.utils.functional.lazy.<locals>.__proxy__ object>
identifier = 'url'
get_field(**kwargs)[source]
class shoop.notify.typology.Phone[source]

Bases: shoop.notify.typology._String

name = <django.utils.functional.lazy.<locals>.__proxy__ object>
identifier = 'phone'
class shoop.notify.typology.Model(model_label)[source]

Bases: shoop.notify.typology.Type

Parameters:model_label (str) – Model label in Django app.Model format (e.g. shoop.Order)
identifier = 'model'
name
model_label = None
unserialize(value)[source]
is_coercible_from(other_type)[source]
get_model()[source]
Return type:django.db.models.Model
get_field(**kwargs)[source]
class shoop.notify.typology.Enum(enum_class)[source]

Bases: shoop.notify.typology.Type

identifier = 'enum'
name
enum_class = None
unserialize(value)[source]
get_field(**kwargs)[source]

Module contents

class shoop.notify.Action(data, validate=True)[source]

Bases: shoop.notify.base.ScriptItem

bindings = {}
execute(context)[source]
Parameters:context (shoop.notify.script.Context) – Script Context
get_template(context)[source]

Get this action’s template instance, bound in the context.

Return type:shoop.notify.template.Template
get_template_values(context, language_preferences=())[source]

Render this Action’s template with data from the given context.

Parameters:
  • context (shoop.notify.script.Context) – Script Context
  • language_preferences (list[str]) – Language preference list. The first language in the template to have values for all fields will be used. Has no effect for UNILINGUAL template_use.
Returns:

Dict of field name -> rendered template text.

Return type:

dict[str, str]|None

identifier = 'action'
name = 'Action'
provide_category = 'notify_action'
template_fields = {}
template_use = <TemplateUse.NONE: 0>
variables = {}
class shoop.notify.Binding(name, type=<class 'shoop.notify.typology.Type'>, required=False, help_text='', constant_use=<ConstantUse.VARIABLE_ONLY: 1>, default=None)[source]

Bases: shoop.notify.base.Variable

accepts_any_type
allow_constant
allow_variable
get_value(context, bind_data)[source]
class shoop.notify.Context(variables=None)[source]

Bases: object

add_log_entry_on_log_target(message, identifier, **kwargs)[source]

Add a log entry on the context’s log target.

The kwargs are passed to the target’s add_log_entry method.

If no log target exists or if it has no add_log_entry method, this method does nothing.

Parameters:
  • message (str) – The message text.
  • identifier (str) – The message identifier. Unlike with add_log_entry, this is required.
  • kwargs (dict) – Other kwargs to pass to add_log_entry
classmethod from_event(event)[source]

Create Context from event.

Return type:shoop.notify.script.Context
classmethod from_variables(**variables)[source]

Create Context from variables.

Return type:shoop.notify.script.Context
get(name, default=None)[source]
get_variables()[source]
log(level, msg, *args, **kwargs)[source]

Log a message with the context’s logger (not the log target). This may be an useful debugging tool.

The parameters are the same as for logging.Logger.log().

log_entry_queryset
set(name, value)[source]
class shoop.notify.Condition(data, validate=True)[source]

Bases: shoop.notify.base.ScriptItem

bindings = {}
identifier = 'condition'
name = 'Condition'
provide_category = 'notify_condition'
test(context)[source]
variables = {}
class shoop.notify.ConstantUse[source]

Bases: enumfields.enums.Enum

An enumeration.

CONSTANT_ONLY = <ConstantUse.CONSTANT_ONLY: 2>
VARIABLE_ONLY = <ConstantUse.VARIABLE_ONLY: 1>
VARIABLE_OR_CONSTANT = <ConstantUse.VARIABLE_OR_CONSTANT: 3>
class shoop.notify.Event(**variable_values)[source]

Bases: shoop.notify.base.Base

bindings = {}
identifier = None
load_variables(variable_values)[source]
log_target
log_target_variable = None
provide_category = 'notify_event'
run()[source]
variables = {}
class shoop.notify.TemplateUse[source]

Bases: enumfields.enums.Enum

An enumeration.

MULTILINGUAL = <TemplateUse.MULTILINGUAL: 2>
NONE = <TemplateUse.NONE: 0>
UNILINGUAL = <TemplateUse.UNILINGUAL: 1>
class shoop.notify.Variable(name, type=<class 'shoop.notify.typology.Type'>, required=True, help_text='')[source]

Bases: object

get_matching_types(variable_dict)[source]