from mother.mothers import *
from mother.speaker import RED

# Classes for the Database Example

# This is a trigger to be esecuted each time that
# a record on stars in insertd (before insertion):

def TriggerOne():
    print RED('Trigger One Fired!!!!')
def TriggerTwo():
    print RED('Trigger Two Fired!!!!')

# Note that the trigger is executed only if the
# record is inserted with Mother

#
## Classes
#

class ClsMoons(DbMother):

  table_name= 'moons_info'

  def __init__(self, store={}, flag= MO_NOA, session= None):

    DbMother.__init__(self, store, flag, session)

class ClsLifes(DbMother):

  table_name= 'lifes'

  def __init__(self, store= {}, flag= MO_NOA, session= None):

    DbMother.__init__(self, store, flag, session)


class ClsPlanets(DbMother, MotherManager):

  table_name= 'planets'

  def __init__(self, store= {}, flag= MO_NOA, session= None):

    DbMother.__init__(self, store, flag, session)

    # Magic Auto-Builded Methods
    self.initRelationManager([ClsLifes])


class ClsStars(DbMother, MotherManager):
  table_name= "stars"
  def __init__(self, store= {}, flag= MO_NOA, session= None):

    # Trigger:
    self.add_trigger(MO_SAVE, MO_BEFORE, TriggerOne)
    self.add_trigger(MO_SAVE, MO_AFTER, TriggerTwo)

    DbMother.__init__(self, store, flag, session)

    # Magic Auto-Builded Methods
    self.initChildManager([ClsPlanets])

