Beispiel #1
0
 def release_has_many(self,rel_table, prefix_path="./"):
     
     if rel_table in self.properties_list:
         # remove raltion from the living model
         self.properties_list.remove(rel_table)
         print "properties_list after release_has_many:" , self.properties_list 
         mod = powlib.load_module( "generate_model" )
         # daclaration of render_model: def render_model(modelname, force, comment, properties=None, nomig=False):
         # remove relation from the persistent model
         mod.render_model( str.lower(self.modelname), True, "", prefix_path, str(self.properties_list) )
     else:
         print "Model: ", self.modelname, " has no has_many relation to ", rel_table
     return
Beispiel #2
0
 def has_many(self,rel_table, prefix_path="./"):
     """ Description:
             Creates the relation property in the model class text definition.                  
         input parameters:    
             rel_table     (type:string) Name of the table to be related.
             prefix_path   (type:string) The new model code will be generated into
                                         prefix_path/models/ 
     """
     ### has_many property is the plural form of the modelname
     #modelname = string.capitalize(powlib.singularize(rel_table))
     #rel_model = powlib.load_class(modelname, modelname)
     #self.__mapper__.add_properties({rel_table: relationship(rel_model.__mapper__)})
     #generate_model.render_model(modelname, noforce, comment, properties=None):
     #return
     if rel_table in self.properties_list:
         print "Model: ", self.modelname, " already has a has_many relation to ", rel_table
         return
     else:
         self.properties_list.append(rel_table)
         mod = powlib.load_module( "generate_model" )
         # daclaration of render_model: def render_model(modelname, force, comment, properties=None, nomig=False):
         mod.render_model( str.lower(self.modelname), True, "", prefix_path, str(self.properties_list))
         #def render_model(modelname, force, comment, prefix_path, properties=None):
         return