-
Notifications
You must be signed in to change notification settings - Fork 0
/
play.py
59 lines (46 loc) · 1.77 KB
/
play.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from sqlalchemy.sql.expression import null
from sqlalchemy_mutable import Mutable, MutableType, MutableModelBase, Query
#
#from sqlalchemy import create_engine, Column, Integer, String
#from sqlalchemy.orm import sessionmaker, scoped_session
#from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, DateTime, Integer, ForeignKey, func
from sqlalchemy.orm import relationship, backref
from sqlalchemy.sql.sqltypes import Boolean
import json
from sqlalchemy.types import TypeDecorator
from base import Base
#from base import TextPickleType
class Play(Base):
__tablename__ = 'plays'
id = Column(Integer, primary_key=True)
chat_id = Column(Integer, unique=True)
editor_enabled = Column(Boolean, default=False)
status = Column(Integer, default=0)
attributes = Column(MutableType)
# menus = Column(MutableType)
created_on = Column(DateTime, default=func.now())
updated_on = Column(DateTime, default=func.now())
game_id = Column(Integer, ForeignKey('games.id'))
game = relationship("Game", back_populates="plays")
def __init__(self, chat_id):
# set mutable column to `Mutable` object
self.chat_id = chat_id
self.attributes = Mutable()
self.attributes = {}
# self.menus = Mutable()
# self.menus = []
def get(self, attribute, default_value=None):
return self.attributes.get(attribute, default_value)
def set(self, attribute, value):
self.attributes[attribute] = value
def unset(self, attribute):
self.attributes.pop(attribute, None)
pass
# def menu_pop(self):
# if len(self.menus)>0:
# return self.menus.pop()
# else:
# return None
# def menu_push(self, value):
# self.menus.append(value)