bottler.labels.models

Labels model graph

Graph of models in the bottler.labels app and related apps.

class bottler.labels.models.Label(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A Label defines a collection of LabelFields used to analyze and add metadata to a dictionary of bottled data.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

add(data)[source]

Takes a dictionary of bottled data and returns the dictionary updated with metadata containing the results of analyses for the Label’s fields.

container_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

create(data)[source]

Takes a dictionary of bottled data and returns a dictionary of metadata containing the results of analyses for the Label’s LabelFields.

fields

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

pizza.toppings and topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

get_fields()[source]

Returns a list of data dictionaries containing the field_name, field_type, and target_type of each of the Label’s fields.

get_structure()[source]

Returns an OrderedDict representing the Label.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <bottler.labels.models.LabelManager object>
preview()[source]

Returns a JSON string representing the Label.

class bottler.labels.models.LabelField(*args, **kwargs)[source]

Bases: bottler.datafields.models.DataField

Defines a field in a Label.

Assigns a Procedure or Inspection to a Bottle to allow data enhancements for bottled data.

CONTENT_TYPES = <Q: (OR: (AND: ('model', 'procedure'), ('app_label', 'procedures')), (AND: ('model', 'inspection'), ('app_label', 'inspections')))>
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

INSPECTION = <Q: (AND: ('model', 'inspection'), ('app_label', 'inspections'))>
exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

PROCEDURE = <Q: (AND: ('model', 'procedure'), ('app_label', 'procedures'))>
analyzer

Provide a generic many-to-one relation through the content_type and object_id fields.

This class also doubles as an accessor to the related object (similar to ForwardManyToOneDescriptor) by adding itself as a model attribute.

analyzer_type

Returns the name of the class for the type of analyzer, which can be either an Inspection or a Procedure.

content_type

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

content_type_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

create(data)[source]

Takes a dictionary of bottled data and returns a dictionary object containing the result of the analysis.

get_field_type_display(**morekwargs)
get_target_type_display(**morekwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

label_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

pizza.toppings and topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

object_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <bottler.datafields.models.DataFieldManager object>
class bottler.labels.models.LabelManager[source]

Bases: cyphon.models.GetByNameManager

Adds methods to the default model manager.

get_queryset()[source]

Overrides the default get_queryset method to select the related BottleFields.