Skip to content

Instantly share code, notes, and snippets.

@minhoryang
Created September 17, 2015 12:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save minhoryang/8b9de6b7a18f2926ddbc to your computer and use it in GitHub Desktop.
class Action(ActionMixIn, db.Model):
__bind_key__ = __tablename__ = "action"
class Action_01_NotResponsed_ByMe(Action):
__bind_key__ = "action"
__tablename__ = "Action_01_NotResponsed_ByMe".lower()
id = db.Column(db.Integer, db.ForeignKey('action.id'), primary_key=True)
class Action_02_NotResponsed_ByYou(Action):
__bind_key__ = "action"
__tablename__ = "Action_02_NotResponsed_ByYou".lower()
id = db.Column(db.Integer, db.ForeignKey('action.id'), primary_key=True)
class Action_03_AskedOut(Action):
__bind_key__ = "action"
__tablename__ = "Action_03_AskedOut".lower()
id = db.Column(db.Integer, db.ForeignKey('action.id'), primary_key=True)
@minhoryang
Copy link
Author

Action_01_NotResponsed_ByMe
Action_02_NotResponsed_ByYou
Action_03_AskedOut
과 같은 부분을 정리하고싶습니다.
Metaclass같은걸로도 될 것 같은데, 궁금합니다.

  1. tablename의 부분에서 자신의 클래스 이름을 받아올 수 있는 방법이 있나요?
  2. Factory처럼 Action_01_NotResponsed_ByMe, Action_02_NotResponsed_ByYou, Action_03_AskedOut 등을 찍어낼 수 있나요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment