#!/usr/bin/env python
##################################################
## DEPENDENCIES
import sys
import os
import os.path
from os.path import getmtime,exists
import time
import types
import __builtin__
from Cheetah.Version import MinCompatibleVersion
from Cheetah.Version import MinCompatibleVersionTuple
from Cheetah.Template import Template
from Cheetah.DummyTransaction import DummyTransaction
from Cheetah.NameMapper import NotFound,valueForName,valueFromSearchList,valueFromFrameOrSearchList
from Cheetah.CacheRegion import CacheRegion
import Cheetah.Filters as Filters
import Cheetah.ErrorCatchers as ErrorCatchers
import time
from Modeling import utils
##################################################
## MODULE CONSTANTS
try:
True, False
except NameError:
True, False = (1==1), (1==0)
VFFSL=valueFromFrameOrSearchList
VFSL=valueFromSearchList
VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.0rc6'
__CHEETAH_versionTuple__ = (2, 0, 0, 'candidate', 6)
__CHEETAH_genTime__ = 1140978986.16941
__CHEETAH_genTimestamp__ = 'Sun Feb 26 19:36:26 2006'
__CHEETAH_src__ = 'Modeling/ModelMasons/Python_bricks/base_module.tmpl'
__CHEETAH_srcLastModified__ = 'Sun Feb 26 19:08:10 2006'
__CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine'
if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
raise AssertionError(
'This template was compiled with Cheetah version'
' %s. Templates compiled before version %s must be recompiled.'%(
__CHEETAH_version__, RequiredCheetahVersion))
##################################################
## CLASSES
class base_module(Template):
##################################################
## CHEETAH GENERATED METHODS
def __init__(self, *args, **KWs):
Template.__init__(self, *args, **KWs)
if not self._CHEETAH__instanceInitialized:
cheetahKWArgs = {}
allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
for k,v in KWs.items():
if k in allowedKWs: cheetahKWArgs[k] = v
self._initCheetahInstance(**cheetahKWArgs)
def respond(self, trans=None):
## CHEETAH: main method generated for this template
if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
trans = self.transaction # is None unless self.awake() was called
if not trans:
trans = DummyTransaction()
_dummyTrans = True
else: _dummyTrans = False
write = trans.response().write
SL = self._CHEETAH__searchList
_filter = self._CHEETAH__currentFilter
########################################
## START - generated method body
# This template will build the <module>Base.py module
write('# Generated by mdl_generate_python_code.py / ')
_v = VFN(VFFSL(SL,"time",True),"strftime",False)("%Y/%m/%d %H:%M") # '$(time.strftime("%Y/%m/%d %H:%M"))' on line 3, col 46
if _v is not None: write(_filter(_v, rawExpr='$(time.strftime("%Y/%m/%d %H:%M"))')) # from line 3, col 46.
write('\n# DO NOT MODIFY THIS FILE -- IT WILL BE OVERWRITTEN\n# Instead, modify ')
_v = VFFSL(SL,"model.packageName",True) # '$(model.packageName)' on line 5, col 19
if _v is not None: write(_filter(_v, rawExpr='$(model.packageName)')) # from line 5, col 19.
write('.')
_v = VFN(VFFSL(SL,"entities",True)[0],"moduleName",False)() # '$(entities[0].moduleName())' on line 5, col 40
if _v is not None: write(_filter(_v, rawExpr='$(entities[0].moduleName())')) # from line 5, col 40.
write('\n')
custom = 1
imported = []
for entity in VFFSL(SL,"entities",True): # generated from line 8, col 1
if VFN(VFFSL(SL,"entity",True),"parentEntity",False)() not in imported: # generated from line 9, col 1
if VFN(VFFSL(SL,"entity",True),"parentEntity",False)() and VFN(VFFSL(SL,"entity",True),"parentEntity",False)() not in VFFSL(SL,"entities",True): # generated from line 10, col 1
write('import ')
_v = VFN(VFN(VFFSL(SL,"entity",True),"parentEntity",False)(),"className",False)() # '$entity.parentEntity().className()' on line 11, col 8
if _v is not None: write(_filter(_v, rawExpr='$entity.parentEntity().className()')) # from line 11, col 8.
write(' # make sure we import in correct order\nfrom ')
_v = VFN(VFFSL(SL,"model",True),"packageName",False)() # '$(model.packageName())' on line 12, col 6
if _v is not None: write(_filter(_v, rawExpr='$(model.packageName())')) # from line 12, col 6.
write('.')
_v = VFN(VFN(VFFSL(SL,"entity",True),"parentEntity",False)(),"moduleName",False)() # '$entity.parentEntity().moduleName()' on line 12, col 29
if _v is not None: write(_filter(_v, rawExpr='$entity.parentEntity().moduleName()')) # from line 12, col 29.
write(' import ')
_v = VFN(VFN(VFFSL(SL,"entity",True),"parentEntity",False)(),"className",False)() # '$entity.parentEntity().className()' on line 12, col 72
if _v is not None: write(_filter(_v, rawExpr='$entity.parentEntity().className()')) # from line 12, col 72.
write('\n')
_v = VFN(VFFSL(SL,"imported",True),"append",False)(VFN(VFFSL(SL,"entity",True),"parentEntity",False)()) # '$imported.append($entity.parentEntity())' on line 13, col 1
if _v is not None: write(_filter(_v, rawExpr='$imported.append($entity.parentEntity())')) # from line 13, col 1.
elif VFFSL(SL,"custom",True): # generated from line 14, col 1
write('from Modeling.CustomObject import CustomObject\n')
custom = 0
write('''from Modeling.Validation import ValidationException
from mx.DateTime import DateTimeFrom
''')
for entity in VFFSL(SL,"entities",True): # generated from line 24, col 1
class_name = str(VFFSL(SL,"entity.className",True))
l_class_name = utils.lower(VFFSL(SL,"entity.className",True))
type_name = VFFSL(SL,"entity.typeName",True)
type_name_id = utils.stringToPythonIdentifier(str(VFFSL(SL,"entity.typeName",True)))
entity_props = list(VFN(VFFSL(SL,"entity",True),"newOrOverriddenPythonProperties",False)())
_v = VFN(VFFSL(SL,"entity_props",True),"sort",False)(lambda x,y: cmp(x.name(), y.name())) # '$entity_props.sort(lambda x,y: cmp(x.name(), y.name()))' on line 30, col 1
if _v is not None: write(_filter(_v, rawExpr='$entity_props.sort(lambda x,y: cmp(x.name(), y.name()))')) # from line 30, col 1.
write('\n')
if VFN(VFFSL(SL,"entity",True),"parentEntity",False)(): # generated from line 31, col 1
write('class ')
_v = VFFSL(SL,"class_name",True) # '$(class_name)' on line 32, col 7
if _v is not None: write(_filter(_v, rawExpr='$(class_name)')) # from line 32, col 7.
write('(')
_v = VFN(VFN(VFFSL(SL,"entity",True),"parentEntity",False)(),"className",False)() # '$(entity.parentEntity().className())' on line 32, col 21
if _v is not None: write(_filter(_v, rawExpr='$(entity.parentEntity().className())')) # from line 32, col 21.
write('):\n')
else: # generated from line 33, col 1
write('class ')
_v = VFFSL(SL,"class_name",True) # '$(class_name)' on line 34, col 7
if _v is not None: write(_filter(_v, rawExpr='$(class_name)')) # from line 34, col 7.
write('(CustomObject):\n')
write(' """\n Base module for ')
_v = VFFSL(SL,"class_name",True) # '$(class_name)' on line 37, col 19
if _v is not None: write(_filter(_v, rawExpr='$(class_name)')) # from line 37, col 19.
write('''s
"""
''')
if not (VFN(VFFSL(SL,"entity",True),"parentEntity",False)()):
write(' __implements__ = CustomObject.__implements__\n')
write('''
def __init__(self):
"Initializer"
# Note: if you modify this method, it is a strong requirement that
# every parameter gets a default value, since the framework needs to be
# able to instanciate an object with no parameter at all.
''')
if VFFSL(SL,"entity.parentEntity",True): # generated from line 49, col 5
write(' ')
_v = VFN(VFN(VFFSL(SL,"entity",True),"parentEntity",False)(),"name",False)() # '$(entity.parentEntity().name())' on line 50, col 5
if _v is not None: write(_filter(_v, rawExpr='$(entity.parentEntity().name())')) # from line 50, col 5.
write('.__init__(self)\n')
for attr in VFFSL(SL,"entity_props",True): # generated from line 52, col 5
if hasattr(VFFSL(SL,"attr",True), 'defaultValueAsPythonStatement'): # generated from line 53, col 5
if not VFFSL(SL,"attr",True) in VFN(VFFSL(SL,"entity",True),"primaryKeyAttributes",False)(): # generated from line 54, col 1
write(' self._')
_v = VFFSL(SL,"attr.name",True) # '$attr.name' on line 55, col 11
if _v is not None: write(_filter(_v, rawExpr='$attr.name')) # from line 55, col 11.
write(' = ')
_v = VFFSL(SL,"attr.defaultValueAsPythonStatement",True) # '$attr.defaultValueAsPythonStatement' on line 55, col 24
if _v is not None: write(_filter(_v, rawExpr='$attr.defaultValueAsPythonStatement')) # from line 55, col 24.
write('\n')
else: # generated from line 56, col 1
write(' self._')
_v = VFFSL(SL,"attr.name",True) # '$attr.name' on line 57, col 11
if _v is not None: write(_filter(_v, rawExpr='$attr.name')) # from line 57, col 11.
write(' = ')
_v = VFFSL(SL,"attr.defaultValueAsPythonStatement",True) # '$attr.defaultValueAsPythonStatement' on line 57, col 24
if _v is not None: write(_filter(_v, rawExpr='$attr.defaultValueAsPythonStatement')) # from line 57, col 24.
write(' # Primary Key: read-only!\n')
for rel in VFFSL(SL,"entity_props",True): # generated from line 61, col 5
if not hasattr(VFFSL(SL,"rel",True), 'defaultValueAsPythonStatement'): # generated from line 62, col 7
if VFN(VFFSL(SL,"rel",True),"isToMany",False)(): # generated from line 63, col 9
write(' self._')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$rel.name()' on line 64, col 11
if _v is not None: write(_filter(_v, rawExpr='$rel.name()')) # from line 64, col 11.
write('=[]\n')
else: # generated from line 65, col 9
write(' self._')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$rel.name()' on line 66, col 11
if _v is not None: write(_filter(_v, rawExpr='$rel.name()')) # from line 66, col 11.
write('=None\n')
write('''
def entityName(self):
"Used by the framework to link this object to its entity"
return "''')
_v = VFFSL(SL,"entity.name",True) # '$(entity.name)' on line 73, col 15
if _v is not None: write(_filter(_v, rawExpr='$(entity.name)')) # from line 73, col 15.
write('" # do not change\n\n')
for attr in VFFSL(SL,"entity_props",True): # generated from line 75, col 3
if hasattr(VFFSL(SL,"attr",True), 'defaultValueAsPythonStatement'): # generated from line 76, col 3
write('\n # Attribute: ')
_v = VFFSL(SL,"attr.name",True) # '$attr.name' on line 78, col 16
if _v is not None: write(_filter(_v, rawExpr='$attr.name')) # from line 78, col 16.
write('\n')
if VFFSL(SL,"attr",True) in VFN(VFFSL(SL,"entity",True),"primaryKeyAttributes",False)(): # generated from line 79, col 1
write(' # This attribute is a primary key: it is a READ-ONLY attribute that should\n # not be changed\n')
write(' def get')
_v = VFN(VFFSL(SL,"utils",True),"capitalizeFirstLetter",False)(attr.name()) # '$utils.capitalizeFirstLetter(attr.name())' on line 83, col 10
if _v is not None: write(_filter(_v, rawExpr='$utils.capitalizeFirstLetter(attr.name())')) # from line 83, col 10.
write('(self):\n "Return the ')
_v = VFFSL(SL,"class_name",True) # '$class_name' on line 84, col 17
if _v is not None: write(_filter(_v, rawExpr='$class_name')) # from line 84, col 17.
write(' / ')
_v = VFFSL(SL,"attr.name",True) # '$attr.name' on line 84, col 31
if _v is not None: write(_filter(_v, rawExpr='$attr.name')) # from line 84, col 31.
write(' attribute value"\n self.willRead()\n return self._')
_v = VFFSL(SL,"attr.name",True) # '$attr.name' on line 86, col 18
if _v is not None: write(_filter(_v, rawExpr='$attr.name')) # from line 86, col 18.
write('\n \n')
if not VFFSL(SL,"attr",True) in VFN(VFFSL(SL,"entity",True),"primaryKeyAttributes",False)(): # generated from line 88, col 1
write(' def set')
_v = VFN(VFFSL(SL,"utils",True),"capitalizeFirstLetter",False)(attr.name()) # '$utils.capitalizeFirstLetter(attr.name())' on line 89, col 10
if _v is not None: write(_filter(_v, rawExpr='$utils.capitalizeFirstLetter(attr.name())')) # from line 89, col 10.
write('(self, ')
_v = VFFSL(SL,"attr.name",True) # '$attr.name' on line 89, col 58
if _v is not None: write(_filter(_v, rawExpr='$attr.name')) # from line 89, col 58.
write('):\n "Change the ')
_v = VFFSL(SL,"class_name",True) # '$class_name' on line 90, col 17
if _v is not None: write(_filter(_v, rawExpr='$class_name')) # from line 90, col 17.
write(' / ')
_v = VFFSL(SL,"attr.name",True) # '$attr.name' on line 90, col 31
if _v is not None: write(_filter(_v, rawExpr='$attr.name')) # from line 90, col 31.
write(' attribute value"\n self.willChange()\n self._')
_v = VFFSL(SL,"attr.name",True) # '$attr.name' on line 92, col 11
if _v is not None: write(_filter(_v, rawExpr='$attr.name')) # from line 92, col 11.
write(' = ')
_v = VFFSL(SL,"attr.name",True) # '$attr.name' on line 92, col 25
if _v is not None: write(_filter(_v, rawExpr='$attr.name')) # from line 92, col 25.
write('\n')
# isClassProperty
write(' ')
# Attributes
write(' ')
write(' \n')
for rel in VFFSL(SL,"entity_props",True): # generated from line 97, col 3
if not hasattr(VFFSL(SL,"rel",True), 'defaultValueAsPythonStatement'): # generated from line 98, col 3
write(' # Relationship: ')
_v = VFFSL(SL,"rel.name",True) # '$rel.name' on line 99, col 19
if _v is not None: write(_filter(_v, rawExpr='$rel.name')) # from line 99, col 19.
write('\n\n')
if VFN(VFFSL(SL,"rel",True),"isToMany",False)(): # generated from line 101, col 3
write(' def get')
_v = VFN(VFFSL(SL,"utils",True),"capitalizeFirstLetter",False)(VFN(VFFSL(SL,"rel",True),"name",False)()) # '$(utils.capitalizeFirstLetter($rel.name()))' on line 102, col 10
if _v is not None: write(_filter(_v, rawExpr='$(utils.capitalizeFirstLetter($rel.name()))')) # from line 102, col 10.
write('(self):\n "Returns the ')
_v = VFFSL(SL,"rel.name",True) # '$(rel.name)' on line 103, col 18
if _v is not None: write(_filter(_v, rawExpr='$(rel.name)')) # from line 103, col 18.
write(' relationship (toMany)"\n self.willRead()\n return self._')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$rel.name()' on line 105, col 18
if _v is not None: write(_filter(_v, rawExpr='$rel.name()')) # from line 105, col 18.
write('\n \n def addTo')
_v = VFN(VFFSL(SL,"utils",True),"capitalizeFirstLetter",False)(VFN(VFFSL(SL,"rel",True),"name",False)()) # '$(utils.capitalizeFirstLetter($rel.name()))' on line 107, col 12
if _v is not None: write(_filter(_v, rawExpr='$(utils.capitalizeFirstLetter($rel.name()))')) # from line 107, col 12.
write('(self, object):\n "Add the ')
_v = VFFSL(SL,"rel.name",True) # '$rel.name' on line 108, col 14
if _v is not None: write(_filter(_v, rawExpr='$rel.name')) # from line 108, col 14.
write(' relationship (toMany)"\n if object not in self._')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$rel.name()' on line 109, col 28
if _v is not None: write(_filter(_v, rawExpr='$rel.name()')) # from line 109, col 28.
write(':\n self.willChange()\n _')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$rel.name()' on line 111, col 8
if _v is not None: write(_filter(_v, rawExpr='$rel.name()')) # from line 111, col 8.
write('=list(self._')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$rel.name()' on line 111, col 31
if _v is not None: write(_filter(_v, rawExpr='$rel.name()')) # from line 111, col 31.
write(')\n _')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$(rel.name())' on line 112, col 8
if _v is not None: write(_filter(_v, rawExpr='$(rel.name())')) # from line 112, col 8.
write('.append(object)\n self._')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$rel.name()' on line 113, col 13
if _v is not None: write(_filter(_v, rawExpr='$rel.name()')) # from line 113, col 13.
write('=tuple(_')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$rel.name()' on line 113, col 32
if _v is not None: write(_filter(_v, rawExpr='$rel.name()')) # from line 113, col 32.
write(')\n \n def removeFrom')
_v = VFN(VFFSL(SL,"utils",True),"capitalizeFirstLetter",False)(VFN(VFFSL(SL,"rel",True),"name",False)()) # '$(utils.capitalizeFirstLetter($rel.name()))' on line 115, col 17
if _v is not None: write(_filter(_v, rawExpr='$(utils.capitalizeFirstLetter($rel.name()))')) # from line 115, col 17.
write('(self, object):\n "Remove the ')
_v = VFFSL(SL,"rel.name",True) # '$rel.name' on line 116, col 17
if _v is not None: write(_filter(_v, rawExpr='$rel.name')) # from line 116, col 17.
write(' relationship (toMany)"\n self.willChange()\n _')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$rel.name()' on line 118, col 6
if _v is not None: write(_filter(_v, rawExpr='$rel.name()')) # from line 118, col 6.
write('=list(self._')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$rel.name()' on line 118, col 29
if _v is not None: write(_filter(_v, rawExpr='$rel.name()')) # from line 118, col 29.
write(')\n _')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$(rel.name())' on line 119, col 6
if _v is not None: write(_filter(_v, rawExpr='$(rel.name())')) # from line 119, col 6.
write('.remove(object)\n self._')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$rel.name()' on line 120, col 11
if _v is not None: write(_filter(_v, rawExpr='$rel.name()')) # from line 120, col 11.
write('=tuple(_')
_v = VFN(VFFSL(SL,"rel",True),"name",False)() # '$rel.name()' on line 120, col 30
if _v is not None: write(_filter(_v, rawExpr='$rel.name()')) # from line 120, col 30.
write(')\n \n')
else: # generated from line 122, col 3
write(' def get')
_v = VFN(VFFSL(SL,"utils",True),"capitalizeFirstLetter",False)(VFN(VFFSL(SL,"rel",True),"name",False)()) # '$(utils.capitalizeFirstLetter($rel.name()))' on line 123, col 10
if _v is not None: write(_filter(_v, rawExpr='$(utils.capitalizeFirstLetter($rel.name()))')) # from line 123, col 10.
write('(self):\n "Return the ')
_v = VFFSL(SL,"rel.name",True) # '$rel.name' on line 124, col 17
if _v is not None: write(_filter(_v, rawExpr='$rel.name')) # from line 124, col 17.
write(' relationship (toOne)"\n self.willRead()\n return self._')
_v = VFFSL(SL,"rel.name",True) # '$rel.name' on line 126, col 18
if _v is not None: write(_filter(_v, rawExpr='$rel.name')) # from line 126, col 18.
write('\n \n def set')
_v = VFN(VFFSL(SL,"utils",True),"capitalizeFirstLetter",False)(VFN(VFFSL(SL,"rel",True),"name",False)()) # '$(utils.capitalizeFirstLetter($rel.name()))' on line 128, col 10
if _v is not None: write(_filter(_v, rawExpr='$(utils.capitalizeFirstLetter($rel.name()))')) # from line 128, col 10.
write('(self, object):\n "Set the ')
_v = VFFSL(SL,"rel.name",True) # '$rel.name' on line 129, col 14
if _v is not None: write(_filter(_v, rawExpr='$rel.name')) # from line 129, col 14.
write(' relationship (toOne)"\n self.willChange()\n self._')
_v = VFFSL(SL,"rel.name",True) # '$rel.name' on line 131, col 11
if _v is not None: write(_filter(_v, rawExpr='$rel.name')) # from line 131, col 11.
write('=object\n ')
# isToMany
write('\n ')
# isClassProperty
write('\n')
########################################
## END - generated method body
return _dummyTrans and trans.response().getvalue() or ""
##################################################
## CHEETAH GENERATED ATTRIBUTES
_CHEETAH__instanceInitialized = False
_CHEETAH_version = __CHEETAH_version__
_CHEETAH_versionTuple = __CHEETAH_versionTuple__
_CHEETAH_genTime = __CHEETAH_genTime__
_CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
_CHEETAH_src = __CHEETAH_src__
_CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
_mainCheetahMethod_for_base_module= 'respond'
## END CLASS DEFINITION
if not hasattr(base_module, '_initCheetahAttributes'):
templateAPIClass = getattr(base_module, '_CHEETAH_templateClass', Template)
templateAPIClass._addCheetahPlumbingCodeToClass(base_module)
# CHEETAH was developed by Tavis Rudd and Mike Orr
# with code, advice and input from many other volunteers.
# For more information visit http://www.CheetahTemplate.org/
##################################################
## if run from command line:
if __name__ == '__main__':
from Cheetah.TemplateCmdLineIface import CmdLineIface
CmdLineIface(templateObj=base_module()).run()
|