[Modeling-cvs] ProjectModeling/Modeling/ModelMasons/Python_bricks init_base.tmpl,NONE,1.1.2.1 base_m
Status: Abandoned
Brought to you by:
sbigaret
Update of /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks In directory sc8-pr-cvs1:/tmp/cvs-serv6229a/ModelMasons/Python_bricks Modified Files: Tag: brch-0_9pre6-1-ModelMasons_base_generation_scheme base_module.tmpl init.tmpl module_base.tmpl Added Files: Tag: brch-0_9pre6-1-ModelMasons_base_generation_scheme init_base.tmpl Log Message: Added the 'MDL' sub-directory containing the files that are overwritten when mdl_generate_python_code.py (option: -B) regenerates a package First proposal. TODO: check the constraint for option -B: a package cannot be generated from a model where a class and at least one of its (direct or indirect) subclasses leave in the same module. --- NEW FILE: init_base.tmpl --- ## This template will build the __init__.py file in the 'base_dir' package ## (see ModelMasons.PyModelMason) #for entities in $entitiesSet: import $(entities[0].moduleName()) #end for Index: base_module.tmpl =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/base_module.tmpl,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** base_module.tmpl 20 Apr 2003 16:10:40 -0000 1.1 --- base_module.tmpl 21 Apr 2003 22:53:05 -0000 1.1.2.1 *************** *** 1,12 **** ## This template will build the <module>Base.py module ! # Modeling ! #set $custom = 1 #for entity in $entities: #if $entity.parentEntity() and $entity.parentEntity() not in $entities: ! from $entity.parentEntity().moduleName() import $entity.parentEntity().className() #elif $custom: from Modeling.CustomObject import CustomObject #set $custom=0 #end if #end for from Modeling.Validation import ValidationException --- 1,18 ---- ## This template will build the <module>Base.py module ! # DO NOT MODIFY THIS FILE -- IT WILL BE OVERWRITTEN ! # Instead, modify $(model.packageName).$(entities[0].moduleName()) ! #set $custom=1 ! #set $imported=[] #for entity in $entities: + #if $entity.parentEntity() not in imported: #if $entity.parentEntity() and $entity.parentEntity() not in $entities: ! import $entity.parentEntity().className() # make sure we import in correct order ! from $(model.packageName()).$entity.parentEntity().moduleName() import $entity.parentEntity().className() ! $imported.append($entity.parentEntity())#slurp #elif $custom: from Modeling.CustomObject import CustomObject #set $custom=0 #end if + #end if #end for from Modeling.Validation import ValidationException *************** *** 22,28 **** $entity_props.sort(lambda x,y: cmp(x.name(), y.name())) #if $entity.parentEntity(): ! class $(class_name)Base($(entity.parentEntity().className())): #else ! class $(class_name)Base(CustomObject): #end if """ --- 28,34 ---- $entity_props.sort(lambda x,y: cmp(x.name(), y.name())) #if $entity.parentEntity(): ! class $(class_name)($(entity.parentEntity().className())): #else ! class $(class_name)(CustomObject): #end if """ *************** *** 84,92 **** self._$attr.name = $attr.name #end if - def validate$utils.capitalizeFirstLetter(attr.name())(self, value): - "Edit this to enforce custom business logic" - if 0: # your custom bizlogic - raise ValidationException - return #end if ##* isClassProperty *# #slurp #end for ##* Attributes *# #slurp --- 90,93 ---- Index: init.tmpl =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/init.tmpl,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** init.tmpl 7 Aug 2002 22:18:48 -0000 1.3 --- init.tmpl 21 Apr 2003 22:53:05 -0000 1.3.4.1 *************** *** 5,9 **** --- 5,14 ---- from Modeling import ModelSet import os, warnings, StringIO, traceback + #if $base_dir: + from $(base_dir).model_$(model_name) import model_src + #else from model_$(model_name) import model_src + #end if + try: if ModelSet.defaultModelSet().modelNamed("$(model_name)") is None: Index: module_base.tmpl =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/module_base.tmpl,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** module_base.tmpl 20 Apr 2003 16:10:40 -0000 1.1 --- module_base.tmpl 21 Apr 2003 22:53:05 -0000 1.1.2.1 *************** *** 1,6 **** ## This template will build the module ! #for entity in $entities: ! from $(entity.className())Base import $(entity.className())Base ! #end for from Modeling.Validation import ValidationException from mx.DateTime import DateTimeFrom --- 1,4 ---- ## This template will build the module ! import $(base_dir) from Modeling.Validation import ValidationException from mx.DateTime import DateTimeFrom *************** *** 8,16 **** #for entity in $entities: ! #set $class_name = str($entity.className) #if $entity.parentEntity(): ! class $(class_name)($(class_name)Base): #derive from $(entity.parentEntity().className()) #else ! class $(class_name)($(class_name)Base): #end if """ --- 6,17 ---- #for entity in $entities: ! #set $class_name = $entity.className() ! #set $module_name = $entity.moduleName() ! #set $entity_props=list($entity.newOrOverriddenPythonProperties()) ! $entity_props.sort(lambda x,y: cmp(x.name(), y.name())) #if $entity.parentEntity(): ! class $(class_name)($(base_dir).$(module_name).$(class_name)): #derive from $(entity.parentEntity().className()) #else ! class $(class_name)($(base_dir).$(module_name).$(class_name)): #end if """ *************** *** 23,27 **** # every parameter gets a default value, since the framework needs to be # able to instanciate an object with no parameter at all. ! $(class_name)Base.__init__(self) #end for --- 24,38 ---- # every parameter gets a default value, since the framework needs to be # able to instanciate an object with no parameter at all. ! $(base_dir).$(module_name).$(class_name).__init__(self) ! ! #for attr in $entity_props: ! #if $attr.isClassProperty() and not $attr in $entity.primaryKeyAttributes(): ! def validate$utils.capitalizeFirstLetter(attr.name())(self, value): ! "Edit this to enforce custom business logic" ! if 0: # your custom bizlogic ! raise ValidationException ! return ! #end if ##* isClassProperty *# ! #end for ##* Attributes *# #slurp #end for |