Ignore:
Timestamp:
03/02/12 13:45:58 (8 years ago)
Author:
mnagni
Message:

Correctly generates DB tables for CEDAEditor
added two Junit tests

Actually can import a configuration file to add further classes to the table generation

In sqlTables.py, still this has to be fixed by hand:

-- Column('role', CI_RoleCode.db_type(), nullable=False) ----> Column('role', CI_RoleCode.db_type())

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/xmi2sqlalchemy/trunk/src/main/resources/velocity/python/pythonClass.vm

    r8084 r8085  
    8989${tab}def ${attr.name}(self, value): 
    9090#if($attr.getParentName()) 
    91 ${tab}${tab}${tab} self._${attr.getParentName().toLowerCase()}.${attr.name} = value 
     91${tab}${tab}${tab}self._${attr.getParentName().toLowerCase()}.${attr.name} = value 
    9292#elseif($attr.subTypes) 
    9393${tab}${tab}valueClass = "%s.%s" % (type(value).__module__,type(value).__name__) 
     
    109109 
    110110#setter($attribute) 
     111#end 
     112#end 
     113 
     114#macro ( enlistKeys $attributes) 
     115#foreach($attribute in $attributes) 
     116self.${attribute.name}#if($foreach.hasNext), #end 
    111117#end 
    112118#end 
     
    167173${tab}${tab}super(${classModel.associatedClass.name}, self).__init__() 
    168174#dogettersetter($attributes) 
     175 
     176${tab}def __key(self): 
     177${tab}${tab}return (#enlistKeys($attributes)) 
     178 
     179${tab}def __eq__(x, y): 
     180${tab}${tab}''' 
     181${tab}${tab}Cannot compare classes which do not define a "__key" attribute  
     182${tab}${tab}''' 
     183${tab}${tab}if hasattr(x, '_%s__key' % (type(x).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)): 
     184${tab}${tab}${tab}return x.__key() == y.__key() 
     185${tab}${tab}return id(x) == id(y) 
     186 
     187${tab}def __hash__(self): 
     188${tab}${tab}return hash(self.__key()) 
    169189#end 
Note: See TracChangeset for help on using the changeset viewer.