module_base.py :  » Database » Modeling-Framework » Modeling-0.9 » Modeling » ModelMasons » Python_bricks » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Database » Modeling Framework 
Modeling Framework » Modeling 0.9 » Modeling » ModelMasons » Python_bricks » module_base.py
#!/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.2043209
__CHEETAH_genTimestamp__ = 'Sun Feb 26 19:36:26 2006'
__CHEETAH_src__ = 'Modeling/ModelMasons/Python_bricks/module_base.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 module_base(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
        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\n')
        for entity in VFFSL(SL,"entities",True): # generated from line 5, col 1
            class_name = VFN(VFFSL(SL,"entity",True),"className",False)()
            module_name = VFN(VFFSL(SL,"entity",True),"moduleName",False)()
            write('from ')
            _v = VFFSL(SL,"base_dir",True) # '$(base_dir)' on line 8, col 6
            if _v is not None: write(_filter(_v, rawExpr='$(base_dir)')) # from line 8, col 6.
            write('.')
            _v = VFFSL(SL,"module_name",True) # '$(module_name)' on line 8, col 18
            if _v is not None: write(_filter(_v, rawExpr='$(module_name)')) # from line 8, col 18.
            write(' import ')
            _v = VFFSL(SL,"class_name",True) # '$(class_name)' on line 8, col 40
            if _v is not None: write(_filter(_v, rawExpr='$(class_name)')) # from line 8, col 40.
            write(' as ')
            _v = VFFSL(SL,"base_dir",True) # '$(base_dir)' on line 8, col 57
            if _v is not None: write(_filter(_v, rawExpr='$(base_dir)')) # from line 8, col 57.
            write('_')
            _v = VFFSL(SL,"module_name",True) # '$(module_name)' on line 8, col 69
            if _v is not None: write(_filter(_v, rawExpr='$(module_name)')) # from line 8, col 69.
            write('_')
            _v = VFFSL(SL,"class_name",True) # '$(class_name)' on line 8, col 84
            if _v is not None: write(_filter(_v, rawExpr='$(class_name)')) # from line 8, col 84.
            write('\n')
        write('''
from Modeling.Validation import ValidationException
from mx.DateTime import DateTimeFrom

''')
        for entity in VFFSL(SL,"entities",True): # generated from line 15, col 1
            class_name = VFN(VFFSL(SL,"entity",True),"className",False)()
            module_name = VFN(VFFSL(SL,"entity",True),"moduleName",False)()
            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 19, col 1
            if _v is not None: write(_filter(_v, rawExpr='$entity_props.sort(lambda x,y: cmp(x.name(), y.name()))')) # from line 19, col 1.
            write('\n')
            if VFN(VFFSL(SL,"entity",True),"parentEntity",False)(): # generated from line 20, col 1
                write('class ')
                _v = VFFSL(SL,"class_name",True) # '$(class_name)' on line 21, col 7
                if _v is not None: write(_filter(_v, rawExpr='$(class_name)')) # from line 21, col 7.
                write('(')
                _v = VFFSL(SL,"base_dir",True) # '$(base_dir)' on line 21, col 21
                if _v is not None: write(_filter(_v, rawExpr='$(base_dir)')) # from line 21, col 21.
                write('_')
                _v = VFFSL(SL,"module_name",True) # '$(module_name)' on line 21, col 33
                if _v is not None: write(_filter(_v, rawExpr='$(module_name)')) # from line 21, col 33.
                write('_')
                _v = VFFSL(SL,"class_name",True) # '$(class_name)' on line 21, col 48
                if _v is not None: write(_filter(_v, rawExpr='$(class_name)')) # from line 21, col 48.
                write('): #derive from ')
                _v = VFN(VFN(VFFSL(SL,"entity",True),"parentEntity",False)(),"className",False)() # '$(entity.parentEntity().className())' on line 21, col 77
                if _v is not None: write(_filter(_v, rawExpr='$(entity.parentEntity().className())')) # from line 21, col 77.
                write('\n')
            else: # generated from line 22, col 1
                write('class ')
                _v = VFFSL(SL,"class_name",True) # '$(class_name)' on line 23, col 7
                if _v is not None: write(_filter(_v, rawExpr='$(class_name)')) # from line 23, col 7.
                write('(')
                _v = VFFSL(SL,"base_dir",True) # '$(base_dir)' on line 23, col 21
                if _v is not None: write(_filter(_v, rawExpr='$(base_dir)')) # from line 23, col 21.
                write('_')
                _v = VFFSL(SL,"module_name",True) # '$(module_name)' on line 23, col 33
                if _v is not None: write(_filter(_v, rawExpr='$(module_name)')) # from line 23, col 33.
                write('_')
                _v = VFFSL(SL,"class_name",True) # '$(class_name)' on line 23, col 48
                if _v is not None: write(_filter(_v, rawExpr='$(class_name)')) # from line 23, col 48.
                write('): \n')
            write('  """\n  ')
            _v = VFFSL(SL,"class_name",True) # '$(class_name)' on line 26, col 3
            if _v is not None: write(_filter(_v, rawExpr='$(class_name)')) # from line 26, col 3.
            write('''s are objects ...
  """
  
  def __init__(self, **kw):
    "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.
    ''')
            _v = VFFSL(SL,"base_dir",True) # '$(base_dir)' on line 34, col 5
            if _v is not None: write(_filter(_v, rawExpr='$(base_dir)')) # from line 34, col 5.
            write('_')
            _v = VFFSL(SL,"module_name",True) # '$(module_name)' on line 34, col 17
            if _v is not None: write(_filter(_v, rawExpr='$(module_name)')) # from line 34, col 17.
            write('_')
            _v = VFFSL(SL,"class_name",True) # '$(class_name)' on line 34, col 32
            if _v is not None: write(_filter(_v, rawExpr='$(class_name)')) # from line 34, col 32.
            write('''.__init__(self)
    for k,v in kw.items():
      self.takeValueForKey(v, k)

''')
            for attr in VFFSL(SL,"entity_props",True): # generated from line 38, col 1
                if VFN(VFFSL(SL,"attr",True),"isClassProperty",False)() and not VFFSL(SL,"attr",True) in VFN(VFFSL(SL,"entity",True),"primaryKeyAttributes",False)(): # generated from line 39, col 1
                    write('  def validate')
                    _v = VFN(VFFSL(SL,"utils",True),"capitalizeFirstLetter",False)(attr.name()) # '$utils.capitalizeFirstLetter(attr.name())' on line 40, col 15
                    if _v is not None: write(_filter(_v, rawExpr='$utils.capitalizeFirstLetter(attr.name())')) # from line 40, col 15.
                    write('''(self, value):
    "Edit this to enforce custom business logic"
    if 0: # your custom bizlogic
      raise ValidationException
    return
''')
                #  isClassProperty 
                write('\n')
            #  Attributes 
            write(' ')
            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_module_base= 'respond'

## END CLASS DEFINITION

if not hasattr(module_base, '_initCheetahAttributes'):
    templateAPIClass = getattr(module_base, '_CHEETAH_templateClass', Template)
    templateAPIClass._addCheetahPlumbingCodeToClass(module_base)


# 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=module_base()).run()


www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.