[Modeling-cvs] ProjectModeling/Modeling/ModelMasons/Python_bricks init_base.tmpl,1.1,1.2 base_module
Status: Abandoned
Brought to you by:
sbigaret
|
From: <sbi...@us...> - 2003-05-26 15:45:22
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks
In directory sc8-pr-cvs1:/tmp/cvs-serv21164/ModelMasons/Python_bricks
Modified Files:
base_module.tmpl init.tmpl module_base.tmpl
Added Files:
init_base.tmpl
Log Message:
Merged changes from brch-0_9pre6-1-ModelMasons_base_generation_scheme to trunk
Index: base_module.tmpl
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/base_module.tmpl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** base_module.tmpl 20 Apr 2003 16:10:40 -0000 1.1
--- base_module.tmpl 26 May 2003 15:44:48 -0000 1.2
***************
*** 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,20 ----
## This template will build the <module>Base.py module
! #import time
! # Generated by mdl_generate_python_code.py / $(time.strftime("%Y/%m/%d %H:%M"))
! # 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
"""
--- 30,36 ----
$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
--- 92,95 ----
Index: init.tmpl
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/init.tmpl,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** init.tmpl 25 Apr 2003 18:39:13 -0000 1.5
--- init.tmpl 26 May 2003 15:44:48 -0000 1.6
***************
*** 1,3 ****
--- 1,5 ----
## This template will build the __init__.py file
+ #import time
+ # Generated by mdl_generate_python_code.py / time.strftime("%Y/%m/%d %H:%M")
#set $model_name = str($model().name())
# Load the model
***************
*** 18,22 ****
--- 20,28 ----
return
try:
+ #if $base_dir:
+ from $(base_dir).model_$(model_name)_pickle import model_pickle
+ #else
from model_$(model_name)_pickle import model_pickle
+ #end if
import cPickle
m=cPickle.loads(model_pickle)
***************
*** 33,37 ****
--- 39,47 ----
try:
+ #if $base_dir:
+ from $(base_dir).model_$(model_name) import model_src
+ #else
from model_$(model_name) import model_src
+ #end if
ModelSet.defaultModelSet().addModelFromXML({'string': model_src})
model=ModelSet.defaultModelSet().modelNamed("$(model_name)")
Index: module_base.tmpl
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/module_base.tmpl,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** module_base.tmpl 25 Apr 2003 18:37:35 -0000 1.2
--- module_base.tmpl 26 May 2003 15:44:48 -0000 1.3
***************
*** 1,6 ****
## This template will build the module
! #for entity in $entities:
! from $(entity.moduleName())Base import $(entity.className())Base
! #end for
from Modeling.Validation import ValidationException
from mx.DateTime import DateTimeFrom
--- 1,6 ----
## This template will build the module
! #import time
! import $(base_dir)
! # Generated by mdl_generate_python_code.py / time.strftime("%Y/%m/%d %H:%M")
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
"""
--- 8,19 ----
#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
--- 26,40 ----
# 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
|