当前位置: 首页>>代码示例>>Python>>正文


Python Template.functionHeader方法代码示例

本文整理汇总了Python中Cheetah.Template.Template.functionHeader方法的典型用法代码示例。如果您正苦于以下问题:Python Template.functionHeader方法的具体用法?Python Template.functionHeader怎么用?Python Template.functionHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cheetah.Template.Template的用法示例。


在下文中一共展示了Template.functionHeader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: makeNextFreeFunc

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import functionHeader [as 别名]
def makeNextFreeFunc( table, var ):
        """
        Make a function that finds the next highest value of
        an integer field; used to auto-increment inserts for integer parts of a primary key
        """
        template = Template( file=templatesPath()+"get_next_free.func.tmpl" )
        template.functionHeader = makeNextFreeHeader( var, CONNECTION_STRING, ' is' )
        template.statement = "select coalesce( max( "+var.varname+" ) + 1, 1 ) from "+table.qualifiedName()
        template.functionName = "Next_Free_"+var.adaName
        template.adaName = var.adaName
        template.default = var.getDefaultAdaValue()
        template.adaType = var.getAdaType( True )
        template.getFunction = makeValueFunction( var, "0", "0" )
        return str( template );
开发者ID:grahamstark,项目名称:ada_mill,代码行数:16,代码来源:ada_specific_postgres.py

示例2: makeNextFreeFunc

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import functionHeader [as 别名]
def makeNextFreeFunc( table, var ):
        """
        Make a function that finds the next highest value of
        an integer field; used to auto-increment inserts for integer parts of a primary key
        """
        template = Template( file=templatesPath()+"get_next_free.func.tmpl" )
        template.functionHeader = makeNextFreeHeader( var, CONNECTION_STRING, ' is' )
        template.statement = "select max( "+var.varname+" ) from "+table.qualifiedName()
        template.functionName = "Next_Free_"+var.adaName
        template.adaName = var.adaName
        template.adaType = var.getAdaType( True )
        template.default = var.getDefaultAdaValue()
        if( var.sqlType == 'BIGINT' ):
                template.whichBinding = 'L'
        else:
                template.whichBinding = 'I'
        s = str(template) 
        return s
开发者ID:grahamstark,项目名称:ada_mill,代码行数:20,代码来源:ada_specific_odbc.py

示例3: makeRetrieveSFunc

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import functionHeader [as 别名]
def makeRetrieveSFunc( table, database ):
        """                                  
         table - Table class from table_model.py
         database - complete enclosuing Database model from  table_model.py
         
         Make a fuction that, for a given table (say 'fred'), takes an sql string as input (just the query part)
         and returns a single  
         list of fred records (fred_list, as declared in the main database declarations ads file). 
         This version has wide_string handling jammed off
         Structure is: 
            - declare local versions of all fred's variables
            - declare aliases (pointers) to these variables, where needed
            - declare length holders for each one
            - make the query by appending the query part to a constant 'select part'
            - prepare the query
            - bind variables/aliase
            - execute 
            - loop round, map the locals to one record
            --    add the variable to the collection
        
         There's a certain amount of trial an error in this..
        """
        instanceName = table.makeName( Format.ada, Qualification.unqualified, ItemType.instanceName )
        outputRecord = table.makeName( Format.ada, Qualification.full, ItemType.table )
        template = Template( file=templatesPath()+"retrieve_wstr.func.tmpl" )       
        template.functionHeader = makeRetrieveSHeader( table, CONNECTION_STRING, ' is' )
        template.listType = table.makeName( Format.ada, Qualification.full, ItemType.alist )
        template.addToMap = "l.append( "+ instanceName +" )"
        template.bindings = []
        template.adaInstanceName = instanceName
        template.variableDecl = instanceName + " : " + outputRecord
        template.adaQualifiedOutputRecord = outputRecord
        
        pos = 0
        for var in table.variables:
                binding = makeBinding( database.databaseAdapter, instanceName, var, pos ) 
                pos += 1
                template.bindings.append( binding )                                        
        s = str(template) 
        return s
开发者ID:grahamstark,项目名称:ada_mill,代码行数:42,代码来源:ada_specific_postgres.py

示例4: makeRetrieveSFunc

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import functionHeader [as 别名]
def makeRetrieveSFunc( table, database ):
        """
         table - Table class from table_model.py
         database - complete enclosuing Database model from  table_model.py
         
         Make a fuction that, for a given table (say 'fred'), takes an sql string as input (just the query part)
         and returns a single  
         list of fred records (fred_list, as declared in the main database declarations ads file). 
         This version has wide_string handling jammed off
         Structure is: 
            - declare local versions of all fred's variables
            - declare aliases (pointers) to these variables, where needed
            - declare length holders for each one
            - make the query by appending the query part to a constant 'select part'
            - prepare the query
            - bind variables/aliase
            - execute 
            - loop round, map the locals to one record
            --    add the variable to the collection
        
         There's a certain amount of trial an error in this..
        """
        template = Template( file=templatesPath()+"retrieve_wstr.func.tmpl" )       
        template.functionHeader = makeRetrieveSHeader( table, CONNECTION_STRING, ' is' )
        template.listType = table.adaQualifiedListName
        template.variableDecl = table.adaInstanceName + " : " + table.adaQualifiedOutputRecord
        template.addToMap = table.adaQualifiedContainerName+".append( l, "+ table.adaInstanceName +" )"
        template.aliasDeclarations = []
        template.pointers = []
        template.lenDeclarations = []
        template.mappingsFromAliasToRecord = []
        template.bindings = []
        pos = 0
        for var in table.variables:
                pos += 1
                alias = var.adaName + ": aliased " + var.odbcType;
                if( var.isStringType() ):
                        isize  = int(var.size);
                        string_padd = '@' * isize
                        alias += " := " + makePaddedString( 4, string_padd, isize ) 
                template.aliasDeclarations.append( alias );
                len_decl = var.adaName + "_len : aliased SQLLEN := " + var.adaName+"'Size";
                template.lenDeclarations.append( len_decl )
                binding = makeBinding( database.databaseAdapter, var, pos ) 
                template.bindings.append( binding )
                if( var.isRealOrDecimalType() or var.isDateType() or var.isStringType() ): ## NOTE: is String type is only because we're trying wide_strings here, otherwise 
                        if( var.isRealOrDecimalType() ):                                   ## there's a simple SQLBind version that doens't need any of this
                                pointer = var.adaName + "_access : Real_Access := "+var.adaName+"'access"
                                mapping = table.adaInstanceName + "." + var.adaName + ":= " + var.adaType + "( "+var.adaName + "_access.all )"                                
                        elif( var.isDateType()):
                                pointer = var.adaName + "_access : Timestamp_Access := "+var.adaName+"'access"
                                mapping = table.adaInstanceName + "." + var.adaName + ":= dodbc.Timestamp_To_Ada_Time( "+var.adaName + "_access.all )"
                        if( var.isStringType() ):    
                                mapping = table.adaInstanceName + "." + var.adaName + " := Slice_To_Unbounded( " + var.adaName + ", 1, Natural( "+var.adaName+"_len ) )"
                                pointer = var.adaName + "_access : String_Access := "+var.adaName+"'access"
                                
                        template.pointers.append( pointer )
                else:  ## integer/enum types
                        if( var.schemaType == 'ENUM' ):
                                mapping = table.adaInstanceName + "." + var.adaName + " := "+ var.adaType+"'Val( " + var.adaName + " )"
                        elif( var.schemaType == 'BOOLEAN' ):
                                mapping = table.adaInstanceName + "." + var.adaName + " := Boolean'Val( " + var.adaName + " )"
                        else:
                                mapping = table.adaInstanceName + "." + var.adaName + " := " + var.adaName 
                template.mappingsFromAliasToRecord.append( mapping )                        
        s = str(template) 
        return s
开发者ID:grahamstark,项目名称:ada_mill,代码行数:69,代码来源:ada_specific_odbc.py


注:本文中的Cheetah.Template.Template.functionHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。