shoop.notify package¶
Subpackages¶
Submodules¶
shoop.notify.base module¶
-
class
shoop.notify.base.Variable(name, type=<class 'shoop.notify.typology.Type'>, required=True, help_text='')[source]¶ Bases:
object
-
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¶
-
-
class
shoop.notify.base.TemplatedBinding(*args, **kwargs)[source]¶ Bases:
shoop.notify.base.Binding
-
class
shoop.notify.base.Base[source]¶ Bases:
object-
identifier= None¶
-
name= None¶
-
description= None¶
-
variables= {}¶
-
bindings= {}¶
-
provide_category= None¶
-
-
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_entrymethod.
-
log_target¶
-
bindings= {}¶
-
variables= {}¶
-
-
class
shoop.notify.base.ScriptItem(data, validate=True)[source]¶ Bases:
shoop.notify.base.Base-
provide_category= None¶
-
get_value(context, binding_name)[source]¶ Get the actual value of a binding from the given script context.
Parameters: - context (shoop.notify.script.Context) – Script Context
- binding_name (str) – Binding name.
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]
-
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'¶
-
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.EnumAn enumeration.
-
NONE= <TemplateUse.NONE: 0>¶
-
UNILINGUAL= <TemplateUse.UNILINGUAL: 1>¶
-
MULTILINGUAL= <TemplateUse.MULTILINGUAL: 2>¶
-
-
class
shoop.notify.enums.ConstantUse[source]¶ Bases:
enumfields.enums.EnumAn 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.EnumAn enumeration.
-
CONTINUE= <StepNext.CONTINUE: 'continue'>¶
-
STOP= <StepNext.STOP: 'stop'>¶
-
-
class
shoop.notify.enums.StepConditionOperator[source]¶ Bases:
enumfields.enums.EnumAn enumeration.
-
ALL= <StepConditionOperator.ALL: 'all'>¶
-
ANY= <StepConditionOperator.ANY: 'any'>¶
-
NONE= <StepConditionOperator.NONE: 'none'>¶
-
shoop.notify.script module¶
-
class
shoop.notify.script.Step(conditions=(), actions=(), next=<StepNext.CONTINUE: 'continue'>, cond_op=<StepConditionOperator.ALL: 'all'>, enabled=True)[source]¶ Bases:
object-
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
-
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_entrymethod.If no log target exists or if it has no
add_log_entrymethod, this method does nothing.Parameters:
-
log_entry_queryset¶
-
classmethod
shoop.notify.settings module¶
shoop.notify.template module¶
-
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: Raises: Whatever Jinja2 might happen to raise
-
class
shoop.notify.template.Template(context, data)[source]¶ Bases:
objectParameters: - context (shoop.notify.script.Context) – Script context
- data (dict) – Template data dictionary
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
-
-
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'¶
-
-
class
shoop.notify.typology.Decimal[source]¶ Bases:
shoop.notify.typology._Number-
name= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
identifier= 'decimal'¶
-
-
class
shoop.notify.typology.Text[source]¶ Bases:
shoop.notify.typology._String-
name= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
identifier= 'text'¶
-
-
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'¶
-
-
class
shoop.notify.typology.URL[source]¶ Bases:
shoop.notify.typology._String-
name= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
identifier= 'url'¶
-
-
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.TypeParameters: model_label (str) – Model label in Django app.Modelformat (e.g.shoop.Order)-
identifier= 'model'¶
-
name¶
-
model_label= None¶
-
get_model()[source]¶ Return type: django.db.models.Model
-
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¶
-
-
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_entrymethod.If no log target exists or if it has no
add_log_entrymethod, this method does nothing.Parameters:
-
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
-
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¶
-
-
class
shoop.notify.Condition(data, validate=True)[source]¶ Bases:
shoop.notify.base.ScriptItem-
bindings= {}¶
-
identifier= 'condition'¶
-
name= 'Condition'¶
-
provide_category= 'notify_condition'¶
-
variables= {}¶
-
-
class
shoop.notify.ConstantUse[source]¶ Bases:
enumfields.enums.EnumAn 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¶
-
log_target¶
-
log_target_variable= None¶
-
provide_category= 'notify_event'¶
-
variables= {}¶
-