def prepare(self): 
     """This method is called when relation is ready to create it's
     PrimaryTable"""
     
     if self.foreign_class is None:
         self.foreign_class = self.owner_class
     self.owner_fk = camel2underscore(self.owner_class.__name__)
     self.foreign_fk = camel2underscore(self.foreign_class.__name__)
     if self.owner_fk == self.foreign_fk:
         self.owner_fk = self.owner_fk + '1'
         self.foreign_fk = self.foreign_fk + '2'
     primary_table_clsname = (
         self.owner_class.__name__ + self.foreign_class.__name__
     )
     primary_table_name = '{0}_{1}'.format(
         self.owner_class.__table_name__, self.foreign_class.__table_name__
     )
         
     self.PrimaryTable = ObjectMeta(
         primary_table_clsname, (ep.Object,), {
             '__table_name__': primary_table_name,
             self.owner_fk: ManyToOne(self.owner_class),
             self.foreign_fk: ManyToOne(self.foreign_class),
             '__pk__': (self.owner_fk + '_id', self.foreign_fk + '_id'),
         }
     )
 def prepare(self): 
     """Called when ready to create a ManyToOne on the other side"""
     self.backref = self.backref or camel2underscore(
         self.owner_class.__name__
     )
     
     self.foreign_field = self.foreign_class.add_field(
        self.backref,
        ListToOne(
            foreign_class=self.owner_class
        ),
     )
    def prepare(self): 
        """Called when ready to create a ManyToOne on the other side"""
        self.backref = self.backref or camel2underscore(
            self.owner_class.__name__
        )
        
        self.foreign_field = None
        for field in self.foreign_class.fields:
            if field.name == self.backref:
                self.foreign_field = field
                break

        if not self.foreign_field:
            self.foreign_field = self.foreign_class.add_field(
                self.backref,
                ManyToOne(
                    foreign_class=self.owner_class, dependent=self.dependent
                ),
            )