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


Python Template.__str__方法代码示例

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


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

示例1: popular

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
def popular(req):
    
    query = req.form.getfirst("nextratesort", "false")

    request = "http://localhost:8010/list/popular"

    if query is not "false":
	request += "?nextratesort=" + query

    pop_data = urllib2.urlopen(request)

    #return pop_data.read()
    t=Template(file='/home/yuanzheng/Public/public_html/cs462/lab3/WebServer/site_tmpl/popular.tmpl')
    
    """ a list, but all elements are dictionaries """
    p_data = json.load(pop_data)
    t.imagelist = p_data["images"]

    t.nextratesort = p_data["nextratesort"]

    """ add more element into each dict, viewurl which involves /view? and 
    the value of imagekey """
    for each in p_data["images"]:
        each["viewurl"] = "/view?imagekey=" + each["imagekey"]


    m = Template(file='/home/yuanzheng/Public/public_html/cs462/lab3/WebServer/site_tmpl/template.tmpl')

    m.main = t.__str__()

    req.content_type = "text/html"
    req.write(m.__str__())
开发者ID:yuanzheng,项目名称:BYU,代码行数:34,代码来源:list.py

示例2: recent

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
def recent(req):

    query = req.form.getfirst("nextsubmitdate", "false")
    
    request = "http://localhost:8010/list/recent"
    if query is not "false":
        request += '?nextsubmitdate=' + query

    recent_data = urllib2.urlopen(request)
    #return recent_data.read()

    t=Template(file='/home/yuanzheng/Public/public_html/cs462/lab3/WebServer/site_tmpl/recent.tmpl')
    r_data = json.load(recent_data)
    t.imagelist = r_data["images"]
   
    t.nextsubmitdate = r_data["nextsubmitdate"]

    """ Add link for each image """
    for each in r_data["images"]:
        each["viewurl"] = "/view?imagekey=" + each["imagekey"]

    #return r_data["images"]
    m = Template(file='/home/yuanzheng/Public/public_html/cs462/lab3/WebServer/site_tmpl/template.tmpl')

    m.main = t.__str__()

    req.content_type = "text/html"
    req.write(m.__str__())
开发者ID:yuanzheng,项目名称:BYU,代码行数:30,代码来源:list.py

示例3: index

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
def index(req):

    #recent_data = urllib2.urlopen("http://imaj-app.lddi.org:8010/list/recent")
    #pop_data = urllib2.urlopen("http://imaj-app.lddi.org:8010/list/popular")

    recent_data = urllib2.urlopen("http://localhost:8010/list/recent")
    pop_data = urllib2.urlopen("http://localhost:8010/list/popular")

    t=Template(file='/home/yuanzheng/Public/public_html/cs462/lab3/WebServer/site_tmpl/index.tmpl')
    
    r_data = json.load(recent_data)
    """ a list, but all elements are dictionaries """
    t.recent = r_data["images"]
   
    """ add more element into each dict, viewurl which involves /view? and 
       the value of imagekey """
    for each in r_data["images"]:
        each["viewurl"] = "view?imagekey=" + each["imagekey"]

    p_data = json.load(pop_data)
    t.popular = p_data["images"]

    for each in p_data["images"]:
        each["viewurl"] = "view?imagekey=" + each["imagekey"]


    m = Template(file='/home/yuanzheng/Public/public_html/cs462/lab3/WebServer/site_tmpl/template.tmpl')

    m.main = t.__str__()

    req.content_type = "text/html"
    req.write(m.__str__())
开发者ID:yuanzheng,项目名称:BYU,代码行数:34,代码来源:index.py

示例4: complete_tmpl

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
def complete_tmpl(req, msg, resp):
    t=Template(file='/home/yuanzheng/Public/public_html/cs462/lab3/WebServer/site_tmpl/submitcomplete.tmpl')
    t.return_msg = resp
    t.submit_msg = msg

    m = Template(file='/home/yuanzheng/Public/public_html/cs462/lab3/WebServer/site_tmpl/template.tmpl')
    m.main = t.__str__()

    req.content_type = "text/html"
    req.write(m.__str__())
开发者ID:yuanzheng,项目名称:BYU,代码行数:12,代码来源:submit.py

示例5: tmpl

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
def tmpl(req):
    t= Template(file='/home/yuanzheng/Public/public_html/cs462/lab2/test.tmpl')
    t.title="Recent Images"
    t.body="this is text"

    m = Template(file='/home/yuanzheng/Public/public_html/cs462/lab2/template.tmpl')
    m.main = t.__str__()


    req.content_type = "text/html"
    req.write(m.__str__())
开发者ID:yuanzheng,项目名称:BYU,代码行数:13,代码来源:index.py

示例6: generate_prover

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
  def generate_prover(self, defs):
    if (self.framework=="GINGER"):
      t = Template(file=PROVER_GINGER_H_TMPL, searchList=[defs]) 
    else:
      t = Template(file=PROVER_ZAATAR_H_TMPL, searchList=[defs]) 
    self.write_to_file(self.output_prefix + PROVER_H, t.__str__())

    if (self.framework=="GINGER"):
      defs['gamma12_file_name'] = "bin/" + self.class_name + GAMMA12;
      t = Template(file=PROVER_GINGER_CC_TMPL, searchList=[defs]) 
    else:
      t = Template(file=PROVER_ZAATAR_CC_TMPL, searchList=[defs]) 
    self.write_to_file(self.output_prefix + PROVER_IMPL, t.__str__())
开发者ID:amiller,项目名称:pantry,代码行数:15,代码来源:zcc_backend.py

示例7: generate_constants_file

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
  def generate_constants_file(self, spec_path, defs):
    defs['constants'] = zcc_parser.generate_constants(spec_path + ".cons")
    defs['is_mapred_comp'] = zcc_parser.generate_mapred_header(self.class_name)
    
    #if (self.language == "c"):
    #  (defs['type_def'], defs['compute_func_definition']) =  self.extract_clean_compute_function(self.class_name)
    #else:
    #  (defs['type_def'], defs['compute_func_definition']) =  ("", "")

    t = Template(file=CONSTANTS_H_TMPL, searchList=[defs]) 
    self.write_to_file(self.output_prefix + CONSTANTS_H, t.__str__())

    t = Template(file=CONSTANTS_IMPL_TMPL, searchList=[defs]) 
    self.write_to_file(self.output_prefix + CONSTANTS_IMPL, t.__str__())
开发者ID:amiller,项目名称:pantry,代码行数:16,代码来源:zcc_backend.py

示例8: addSymbolToOrig

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
def addSymbolToOrig(conf,inputs,outputs):
    import sys
    from Cheetah.Template import Template
    f=open(conf["main"]["dataPath"]+"/symbols.sym","r")
    newContent=""
    str=f.read()
    f.close()
    i=0
    b=str.split('SYMBOL\n')
    for a in b:
        if a!="" and a!='\n':
            if i+1 < len(b):
                if newContent!="":
                    newContent+='SYMBOL\n'+a
                else:
                    newContent+=a
            else:
                print >> sys.stderr,a[:len(a)-4]
                newContent+='SYMBOL\n'+a[:len(a)-5]
            i+=1
    t=Template(file=conf["main"]["templatesPath"]+"/Manager/Styler/Symbols.sym.tmpl",searchList={"conf": conf,"inputs": inputs,"outputs": outputs})
    newContent+=t.__str__().replace('SYMBOLSET\n',"")
    f=open(conf["main"]["dataPath"]+"/symbols.sym","w")
    f.write(newContent)
    f.close()
    outputs["Result"]["value"]=zoo._("Symbol added.")
    return 3
开发者ID:ThomasG77,项目名称:mapmint,代码行数:29,代码来源:service.py

示例9: index

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
 def index(self):
     """ Action that displays the main data table. """
     self.logger.info("recieved a request to layer data from local database")
     dto = self.data_manager.get_data()
     data = [{'dto' : dto}]
     template = Template ( file = 'phedex_monitor/template/data_table.tmpl',
         searchList = data)
     return template.__str__()
开发者ID:CMSCompOps,项目名称:MonitoringScripts,代码行数:10,代码来源:application_controller.py

示例10: write_zaatar

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
  def write_zaatar(self, defs):
    #Write verifier's header
    t = Template(file=VERIFIER_ZAATAR_H_TMPL, searchList=[defs]) 
    self.write_to_file(self.output_prefix + VERIFIER_H, t.__str__())

    #Write verifier's code
    defs['load_qap'] = zcc_parser.generate_load_qap("bin/" + self.class_name + QAP)

    t = Template(file=VERIFIER_ZAATAR_CC_TMPL, searchList=[defs])     
    self.write_to_file(self.output_prefix + VERIFIER_IMPL, t.__str__())

    #Write A,B,C matrices
    #t = Template(file=QAP_TMPL, searchList=[defs])
    #self.write_to_file("bin/"+ self.class_name +  QAP, t.__str__()) 
 
    #Write the driver
    defs['comp_parameters'] = zcc_parser.generate_zaatar_comp_params() 
    t = Template(file=MAIN_ZAATAR_TMPL, searchList=[defs])     
    self.write_to_file(self.output_prefix + ".cpp", t.__str__()) 
开发者ID:amiller,项目名称:pantry,代码行数:21,代码来源:zcc_backend.py

示例11: modelClass

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
def modelClass(data):
    # 如果同时加载多个模板  
    tmpls = data['templateName'].split(',')
    fileNames = data['outputFileName'].split(',')
    if(len(tmpls) != len(fileNames)):
        print 'init.conf read template error...'
        return
    for i in range(len(tmpls)):
        templatePath = './templates/' + tmpls[i]
        code = Template(file=templatePath, searchList=[data])
        saveFile(code.__str__(), data['outputPath'] + "/" + fileNames[i])
开发者ID:AlexFinder,项目名称:CodeGen,代码行数:13,代码来源:CodeGenerator.py

示例12: write_ginger

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
  def write_ginger(self, defs, spec_file):
    #Write verifier's header
    t = Template(file=VERIFIER_GINGER_H_TMPL, searchList=[defs]) 
    self.write_to_file(self.output_prefix + VERIFIER_H, t.__str__())

    #Write verifier's code
    gamma0 = zcc_parser.generate_gamma0(spec_file)
    gamma12 = zcc_parser.generate_gamma12(spec_file) #these routines generate chi
    defs['gamma12_file_name'] = "bin/" + self.class_name + GAMMA12;
    defs['gamma0_file_name'] = "bin/" + self.class_name + GAMMA0;
    t = Template(file=VERIFIER_GINGER_CC_TMPL, searchList=[defs])
    self.write_to_file(self.output_prefix + VERIFIER_IMPL, t.__str__())

    self.write_to_file("bin/"+self.class_name+GAMMA12, gamma12)
    self.write_to_file("bin/"+self.class_name+GAMMA0, gamma0)

    #Write the driver
    defs['comp_parameters'] = zcc_parser.generate_ginger_comp_params()
    t = Template(file=MAIN_GINGER_TMPL, searchList=[defs])     
    self.write_to_file(self.output_prefix + ".cpp", t.__str__()) 
开发者ID:amiller,项目名称:pantry,代码行数:22,代码来源:zcc_backend.py

示例13: submit_page

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
def submit_page(req, error):
   
    t=Template(file='/home/yuanzheng/Public/public_html/cs462/lab3/WebServer/site_tmpl/submit.tmpl')

    t.errorlist = error

    if len(error) is not 0:
        imageurl = req.form.getfirst("imageurl")
        detailurl = req.form.getfirst("detailurl")
        tags = req.form.getfirst("tags")
        description = req.form.getfirst("description")
        submituser = req.form.getfirst("submituser")
        t.f = {'imageurl':imageurl, 'detailurl':detailurl, 'tags':tags, 'description':description, 'submituser':submituser}
    else:
        t.f = {'imageurl':"", 'detailurl':"", 'tags':"", 'description':"", 'submituser':""}

    
    m = Template(file='/home/yuanzheng/Public/public_html/cs462/lab3/WebServer/site_tmpl/template.tmpl')

    m.main = t.__str__()
    
    req.content_type = "text/html"
    req.write(m.__str__())
开发者ID:yuanzheng,项目名称:BYU,代码行数:25,代码来源:submit.py

示例14: set_state_manually

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
 def set_state_manually(self, from_node=None, to_node=None, new_state=None):
     """ Action for over-riding links statuses manually. """
     # this is a request..
     if from_node==None and to_node==None and new_state==None:
         
         data = self.data_manager.get_data_for_manual_status_setting()
         data = [{'data' : data}]
         template = Template ( file = 'phedex_monitor/template/set_state_manually.tmpl',
             searchList = data)
         return template.__str__()
 
     # this is a form submit..
     else:
         result_string = self.data_manager.set_state_manually(from_node, to_node, new_state)
         return result_string
开发者ID:CMSCompOps,项目名称:MonitoringScripts,代码行数:17,代码来源:application_controller.py

示例15: view

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import __str__ [as 别名]
def view(req):

    """ get the request """
    imagekey = req.form.getfirst("imagekey","")
    imagekey = cgi.escape(imagekey)
    
    """ build a new url, and send request to appServer """
    url = "http://localhost:8010/image?imagekey=" + imagekey

    """  urlopen() GET Request     """
    imagedata = urllib2.urlopen(url)
    #return imagedata.read()
    i_data = json.load(imagedata)


    t=Template(file='/home/yuanzheng/Public/public_html/cs462/lab3/WebServer/site_tmpl/view.tmpl')
    t.image = i_data

    m = Template(file='/home/yuanzheng/Public/public_html/cs462/lab3/WebServer/site_tmpl/template.tmpl')

    m.main = t.__str__()

    req.content_type = "text/html"
    req.write(m.__str__())
开发者ID:yuanzheng,项目名称:BYU,代码行数:26,代码来源:index.py


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