add some re-usable APIs

define some pending/ready helpers as static constants on orm.Spawner

allows treating orm.Spawner the same as Spawner wrappers,
as long as `.active` etc. checks are performed first
This commit is contained in:
Min RK
2018-09-17 16:45:19 +02:00
parent cbe4095533
commit 9031b9aa57
3 changed files with 41 additions and 0 deletions

View File

@@ -135,6 +135,16 @@ class User(Base):
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(Unicode(255), unique=True)
# properties on the spawner wrapper
# some APIs get these low-level objects
# when the spawner isn't running,
# for which these should all be False
active = running = ready = False
pending = None
@property
def orm_spawner(self):
return self
_orm_spawners = relationship(
"Spawner",
backref="user",