Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import sqlalchemy as sa | ||
from meta import * | ||
from core import * | ||
from sqlalchemy import types, Column, Table, UniqueConstraint | ||
|
||
import meta | ||
import types as _types | ||
import domain_object | ||
# se overwrite datetime somewhere in our importing | ||
from datetime import datetime | ||
|
||
__all__ = ['TaskStatus', 'task_status_table'] | ||
|
||
task_status_table = Table('task_status', metadata, | ||
Column('id', UnicodeText, primary_key=True, default=_types.make_uuid), | ||
Column('entity_id', UnicodeText, nullable=False), | ||
Column('entity_type', UnicodeText, nullable=False), | ||
Column('task_type', UnicodeText, nullable=False), | ||
Column('key', UnicodeText, nullable=False), | ||
Column('value', UnicodeText, nullable=False), | ||
Column('state', UnicodeText), | ||
Column('error', UnicodeText), | ||
Column('last_updated', DateTime, default=datetime.now), | ||
sa.UniqueConstraint('entity_id', 'task_type', 'key') | ||
task_status_table = Table('task_status', meta.metadata, | ||
Column('id', types.UnicodeText, primary_key=True, default=_types.make_uuid), | ||
Column('entity_id', types.UnicodeText, nullable=False), | ||
Column('entity_type', types.UnicodeText, nullable=False), | ||
Column('task_type', types.UnicodeText, nullable=False), | ||
Column('key', types.UnicodeText, nullable=False), | ||
Column('value', types.UnicodeText, nullable=False), | ||
Column('state', types.UnicodeText), | ||
Column('error', types.UnicodeText), | ||
Column('last_updated', types.DateTime, default=datetime.now), | ||
UniqueConstraint('entity_id', 'task_type', 'key') | ||
) | ||
|
||
class TaskStatus(domain_object.DomainObject): | ||
@classmethod | ||
def get(cls, reference): | ||
'''Returns a task status object referenced by its id.''' | ||
query = Session.query(cls).filter(cls.id==reference) | ||
query = meta.Session.query(cls).filter(cls.id==reference) | ||
return query.first() | ||
|
||
mapper(TaskStatus, task_status_table) | ||
meta.mapper(TaskStatus, task_status_table) |