Permalink
Browse files

Some bug fixes to SkillClass.py. Still not actually working or

whatever.
  • Loading branch information...
1 parent b34cfb3 commit 88e87677232008e3f6b1dddf09c33032f0083792 @drestuart committed May 2, 2012
Showing with 23 additions and 8 deletions.
  1. +23 −8 src/skills/SkillClass.py
View
31 src/skills/SkillClass.py
@@ -21,11 +21,15 @@ class SkillTransferRatio(Base):
__tablename__ = "skill_transfer_ratio"
- fromSkillId = Column(Integer, ForeignKey("skills.id"), primary_key=True)
- toSkillId = Column(Integer, ForeignKey("skills.id"), primary_key=True)
- fromSkill = relationship("skills")
+ id = Column(Integer, primary_key=True)
+ fromSkillId = Column(Integer, ForeignKey("skills.id"))
+ toSkillId = Column(Integer, ForeignKey("skills.id"))
+ fromSkill = relationship("Skill", primaryjoin = "skills.id==skill_transfer_ratio.fromSkillId")
ratio = Column(Float)
+ # Constraints
+ UniqueConstraint(fromSkillId, toSkillId)
+
def __init__(self, fromSkill, toSkill, ratio):
self.ratio = ratio
@@ -84,14 +88,16 @@ class Skill(Base):
subskills = relationship("Skill", backref="parentskill")
parentId = Column(Integer, ForeignKey('skills.id'))
name = Column(String, unique = True)
- crossSkills = relationship("skill_transfer_ratio", backref="toSkill")
+ crossSkills = relationship("SkillTransferRatio", backref="toSkill")
def __init__(self, name, parent = None):
-
+ print "Initializing " + name
self.name = name
if parent:
- self.setParent(parent)
+ print "Adding parent " + parent.getName()
+ self.setParentskill(parent)
+ self.setParentId(parent.getId())
def getId(self):
return self.id
@@ -157,7 +163,7 @@ class SkillRating(Base):
This class actually describes a particular person's skill.
'''
- def __init__(self, person, rating, skill):
+ def __init__(self, person, skill, rating):
self.person = person
self.rating = rating
self.skill = skill
@@ -215,10 +221,19 @@ def main():
db.saveDB.start()
+ print "Creating Skills"
+ parenting = Skill("parenting")
+ cooking = Skill("cooking", parenting)
+ drinking = Skill("drinking")
+ print "Creating transfer ratio"
+ drinkingHelps = SkillTransferRatio(drinking, parenting, 0.5)
+ print "Building poor Joe"
+ joeParenting = SkillRating("Joe", parenting, 50)
+ joeHasAProblem = SkillRating("Joe", drinking, 75)
-
+ db.saveDB.saveAll([parenting, cooking, drinking, drinkingHelps, joeHasAProblem, joeParenting])

0 comments on commit 88e8767

Please sign in to comment.