记录学习 CherryPy 自带的教程的心得

-- ZoomQuiet [2005-02-01 04:19:14]

CherryPy教程

有关教程

教程展示了 CherryPy 是如何工作的, 在学习本教程后,开发者应该可以利用 CherryPy 独有的途径来快速开发 Web 应用了! 假定你具有基本的Python 编程经验, 其实也不一定, 只是一定要对"面向对象编程思想"有足够的了解就可以开始学习CP2的愉快旅程了!

知识准备

头一个CherryPy应用

概念

从表单接受数据


真正的惊奇之旅!

tutorial

随包提供的教程脚本,是体现Python 自说明的最好示范!

01_helloworld.py

02_expose_methods.py

03_get_and_post.py

04_complex_site.py

05_derived_objects.py

06_aspects.py

07_default_method.py

08_sessions.py

09_generators_and_yield.py

bonus-sqlobject.py

Continuation

示例:

    def query(self):
        phones = {'albert': '134663', 'ying':'133'}

        yield '''
<html>
<body>
<form method="post" action="/query?_resume=%d">
Name:<input name="name"/><br/>
<input type="submit" name="submit" value="查询">
</form>
</body></html>''' % cherrypy.request.resume_id

        name = cherrypy.request.paramMap.get("name")

        if name in phones.keys():
            yield name, phones[name]

        else:
            yield """Not found<br/>


    query = cherrypy.expose(cherryflow.flow(query))

反馈

CherryPyTut (last edited 2009-12-25 07:09:54 by localhost)