Instantiate mutators when a mutated module is created / loaded from DB. Some bug fixes for a few things.

This commit is contained in:
blitzmann
2018-06-10 01:10:53 -04:00
parent fe47ebd1f5
commit e8b56b076b
7 changed files with 69 additions and 14 deletions

View File

@@ -18,6 +18,7 @@
# ===============================================================================
from sqlalchemy import Table, Column, Integer, ForeignKey, CheckConstraint, Boolean, DateTime
from sqlalchemy.orm.collections import attribute_mapped_collection
from sqlalchemy.orm import relation, mapper
import datetime
@@ -47,6 +48,7 @@ mapper(Module, modules_table,
"mutators": relation(
Mutator,
backref="module",
cascade="all,delete-orphan"
cascade="all,delete-orphan",
collection_class=attribute_mapped_collection('attrID')
)
})

View File

@@ -25,7 +25,7 @@ from eos.db import saveddata_meta
from eos.saveddata.mutator import Mutator
mutator_table = Table("mutators", saveddata_meta,
Column("moduleID", Integer, ForeignKey("modules.ID"), nullable=False, index=True),
Column("moduleID", Integer, ForeignKey("modules.ID"), primary_key=True, index=True),
Column("attrID", Integer, primary_key=True, index=True),
Column("value", Float, nullable=False),
Column("created", DateTime, nullable=True, default=datetime.datetime.now),