ORM Python Module

Cart Object Relational Model.

Using PeeWee to implement the ORM.

class pacifica.cartd.orm.Cart(*args, **kwargs)[source]

Cart object model.

DoesNotExist

alias of CartDoesNotExist

_meta = <peewee.Metadata object>
_schema = <peewee.SchemaManager object>
bundle = <BooleanField: Cart.bundle>
bundle_path = <CharField: Cart.bundle_path>
cart_uid = <CharField: Cart.cart_uid>
carttasks_set
creation_date = <DateTimeField: Cart.creation_date>
deleted_date = <DateTimeField: Cart.deleted_date>
error = <TextField: Cart.error>
file_set
id = <PrimaryKeyField: Cart.id>
status = <TextField: Cart.status>
updated_date = <DateTimeField: Cart.updated_date>
class pacifica.cartd.orm.CartBase(*args, **kwargs)[source]

Base Cart Model class.

DoesNotExist

alias of CartBaseDoesNotExist

_meta = <peewee.Metadata object>
_schema = <peewee.SchemaManager object>
classmethod atomic()[source]

Do the DB atomic bits.

classmethod database_close()[source]

Close the database connection.

classmethod database_connect()[source]

Make sure database is connected.

Dont reopen connection.

id = <AutoField: CartBase.id>
reload()[source]

Reload my current state from the DB.

class pacifica.cartd.orm.CartSystem(*args, **kwargs)[source]

Cart Schema Version Model.

DoesNotExist

alias of CartSystemDoesNotExist

_meta = <peewee.Metadata object>
_schema = <peewee.SchemaManager object>
classmethod get_or_create_version()[source]

Set or create the current version of the schema.

classmethod get_version()[source]

Get the current version as a tuple.

classmethod is_equal()[source]

Check to see if schema version matches code version.

classmethod is_safe()[source]

Check to see if the schema version is safe for the code.

part = <CharField: CartSystem.part>
value = <IntegerField: CartSystem.value>
class pacifica.cartd.orm.CartTasks(*args, **kwargs)[source]

List of tasks based on a cart ID.

DoesNotExist

alias of CartTasksDoesNotExist

_meta = <peewee.Metadata object>
_schema = <peewee.SchemaManager object>
cart_id = <ForeignKeyField: CartTasks.cart_id>
cart_id_id = <ForeignKeyField: CartTasks.cart_id>
celery_task_id = <CharField: CartTasks.celery_task_id>
id = <AutoField: CartTasks.id>
class pacifica.cartd.orm.File(*args, **kwargs)[source]

File object model to keep track of what’s been downloaded for a cart.

DoesNotExist

alias of FileDoesNotExist

_meta = <peewee.Metadata object>
_schema = <peewee.SchemaManager object>
bundle_path = <CharField: File.bundle_path>
cart = <ForeignKeyField: File.cart>
cart_id = <ForeignKeyField: File.cart>
error = <TextField: File.error>
file_name = <CharField: File.file_name>
hash_type = <CharField: File.hash_type>
hash_value = <CharField: File.hash_value>
id = <PrimaryKeyField: File.id>
status = <TextField: File.status>
class pacifica.cartd.orm.OrmSync[source]

Special module for syncing the orm.

This module should incorporate a schema migration strategy.

The supported versions migrating forward must be in a versions array containing tuples for major and minor versions.

The version tuples are directly translated to method names in the orm_update class for the update between those versions.

Example Version Control:

class orm_update:
  versions = [
    (0, 1),
    (0, 2),
    (1, 0),
    (1, 1)
  ]

  def update_0_1_to_0_2():
      pass
  def update_0_2_to_1_0():
      pass

The body of the update should follow peewee migration practices. http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#migrate

static create_tables()[source]

Create the tables if they don’t exist.

static dbconn_blocking()[source]

Wait for the db connection.

classmethod update_0_1_to_1_0()[source]

Update by adding the boolean column.

classmethod update_1_0_to_2_0()[source]

Update by adding the boolean column.

classmethod update_tables()[source]

Update the database to the current version.

versions = [(0, 1), (1, 0), (2, 0)]