예제 #1
0
class TaskInfo(_TableLayout):
    """
    Task table with the required fields to help the user work
    with their task nodes.
    """
    node_name = _Field.TextField()
    name = _Field.TextField()
    state = _Field.TextField()
    type = _Field.TextField()
예제 #2
0
class NodeRegister(_TableLayout):
    """
    Table to identify nodes
    """
    name = _Field.TextField(unique=True, pk=True)
    status = _Field.TextField()
    port = _Field.IntField()

    def __eq__(self, other):
        return self.name == other.name

    def __hash__(self):
        return hash(self.name)
예제 #3
0
class TaskRegister(_TableLayout):
    """
    Task table with the required fields to help the user work
    with their task nodes.
    """
    node = _Field.ForeignKeyField(NodeRegister)

    # -- The name of this task
    name = _Field.TextField()

    # -- The current state of the task
    state = _Field.TextField(default='pending')

    # -- The endpoint that we use to construct
    #    requests for the task
    endpoint = _Field.TextField()

    # -- The type of this task
    type = _Field.TextField()

    @classmethod
    def unqiue_constraints(cls):
        return (('node', 'name'), )
예제 #4
0
class TableDefinition(_TableLayout):
    """
    Table describing the migrations that we've gone through for our
    tables.
    """
    table_name = _Field.TextField()
    table_layout = _Field.JSONField()

    @classmethod
    def register_table(cls, interface, table: _TableLayout) -> None:
        """
        Based on the layout of the table, we have to convert everything
        to json
        """
        interface.create(TableDefinition,
                         table_name=table.db_name(),
                         table_layout=table.db_layout())
예제 #5
0
 class SomeRelation(_TableLayout):
     test = _Field.ForeignKeyField(TestTable)
     foo = _Field.TextField(null=True)
예제 #6
0
 class NullOk(_TableLayout):
     blarg = _Field.TextField(null=True)
예제 #7
0
 class MyTable(_TableLayout):
     numba = _Field.IntField(unique=True)
     foo = _Field.TextField()
예제 #8
0
 class MyTable(_TableLayout):
     numba = _Field.IntField()
     foo = _Field.TextField()