- 部分 I. Python 入门
- 第 1 章 Python 入门
- 第 2 章 Python Package Index (PyPI)
- 第 3 章 Python 模块
- 第 4 章 数据类型
- 第 5 章 数据结构
- 第 6 章 Class
- 第 7 章 Input/Output
- 第 8 章 Pipe
- 第 9 章 Library
- 9.2. 随机数
- 9.3. Python 多线程
- 9.13. syslog
- 9.5. Socket
- 9.6. subprocess
- 9.7. YAML
- 9.8. Daemon
- 9.9. python-memcached
- 9.10. Pyro - Pyro is short for PYthon Remote Objects
- 9.11. Python Imaging Library
- 9.12. getopt – Command line option parsing
- 9.14. python-subversion
- 9.15. SimpleHTTPServer
- 9.16. fuse-python.x86_64 : Python bindings for FUSE - filesystem in userspace
- 9.17. Network
- 9.18. Python-spdylay - Spdylay Python Extension Module
- 9.19. mechanize
- 9.20. Dominate
- 第 10 章 Frameworks
- 第 12 章 终端环境开发
- 部分 II. Python 数据分析
- 第 13 章 Crawler
- 第 14 章 Scrapy - Python web scraping and crawling framework
- 第 15 章 Pandas - Python Data Analysis Library
- 第 16 章 股票
- 第 17 章 数据可视化
- 部分 III. 人工智能 AI
- 第 18 章 OCR
- 第 19 章 语音处理
- 第 20 章 视频
- 第 21 章 人脸识别
- 第 22 章 自然语言处理
- 第 23 章 自动化运维
- 第 24 章 办公自动化
- 第 25 章 OpenCV
- 第 26 章 图形开发
- 第 27 章 3rdparty toolkit
- 第 29 章 实用代码
- 第 30 章 FAQ
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
10.2. Pylons
10.2. Pylons
10.2.1. Getting Started with Pylons
10.2.1.1. Installing
[neo@development ~]$ curl http://pylonshq.com/download/1.0/go-pylons.py | python - mydevenv [neo@development ~]$ source mydevenv/bin/activate (mydevenv)[neo@development ~]$ (mydevenv)[neo@development ~]$ paster create -t pylons helloworld
Running the application
(mydevenv)[neo@development ~]$ cd helloworld (mydevenv)[neo@development helloworld]$ paster serve --reload development.ini Starting subprocess with file monitor Starting server in PID 26895. 16:38:39,051 INFO [paste.httpserver.ThreadPool] Cannot use kill_thread_limit as ctypes/killthread is not available serving on http://127.0.0.1:5000
create a controller
(mydevenv)[neo@development helloworld]$ paster controller hello Creating /home/neo/helloworld/helloworld/controllers/hello.py Creating /home/neo/helloworld/helloworld/tests/functional/test_hello.py
http://192.168.3.9:5000/hello/index
10.2.1.2. Debian/Ubuntu
$ sudo apt-cache search pylons $ sudo apt-get install python-pylons $ paster create -t pylons helloworld /usr/lib/pymodules/python2.6/pylons/templating.py:610: UserWarning: Unbuilt egg for setuptools [unknown version] (/usr/lib/python2.6/dist-packages) Engine = entry_point.load() Selected and implied templates: Pylons#pylons Pylons application template Variables: egg: helloworld package: helloworld project: helloworld Enter template_engine (mako/genshi/jinja2/etc: Template language) ['mako']: Enter sqlalchemy (True/False: Include SQLAlchemy 0.5 configuration) [False]: True Creating template pylons Creating directory ./helloworld Recursing into +package+ Creating ./helloworld/helloworld/ Copying __init__.py_tmpl to ./helloworld/helloworld/__init__.py Recursing into config Creating ./helloworld/helloworld/config/ Copying __init__.py_tmpl to ./helloworld/helloworld/config/__init__.py Copying deployment.ini_tmpl_tmpl to ./helloworld/helloworld/config/deployment.ini_tmpl Copying environment.py_tmpl to ./helloworld/helloworld/config/environment.py Copying middleware.py_tmpl to ./helloworld/helloworld/config/middleware.py Copying routing.py_tmpl to ./helloworld/helloworld/config/routing.py Recursing into controllers Creating ./helloworld/helloworld/controllers/ Copying __init__.py_tmpl to ./helloworld/helloworld/controllers/__init__.py Copying error.py_tmpl to ./helloworld/helloworld/controllers/error.py Recursing into lib Creating ./helloworld/helloworld/lib/ Copying __init__.py_tmpl to ./helloworld/helloworld/lib/__init__.py Copying app_globals.py_tmpl to ./helloworld/helloworld/lib/app_globals.py Copying base.py_tmpl to ./helloworld/helloworld/lib/base.py Copying helpers.py_tmpl to ./helloworld/helloworld/lib/helpers.py Recursing into model Creating ./helloworld/helloworld/model/ Copying __init__.py_tmpl to ./helloworld/helloworld/model/__init__.py Copying meta.py_tmpl to ./helloworld/helloworld/model/meta.py Recursing into public Creating ./helloworld/helloworld/public/ Copying bg.png to ./helloworld/helloworld/public/bg.png Copying favicon.ico to ./helloworld/helloworld/public/favicon.ico Copying index.html_tmpl to ./helloworld/helloworld/public/index.html Copying pylons-logo.gif to ./helloworld/helloworld/public/pylons-logo.gif Recursing into templates Creating ./helloworld/helloworld/templates/ Recursing into tests Creating ./helloworld/helloworld/tests/ Copying __init__.py_tmpl to ./helloworld/helloworld/tests/__init__.py Recursing into functional Creating ./helloworld/helloworld/tests/functional/ Copying __init__.py_tmpl to ./helloworld/helloworld/tests/functional/__init__.py Copying test_models.py_tmpl to ./helloworld/helloworld/tests/test_models.py Copying websetup.py_tmpl to ./helloworld/helloworld/websetup.py Copying MANIFEST.in_tmpl to ./helloworld/MANIFEST.in Copying README.txt_tmpl to ./helloworld/README.txt Copying development.ini_tmpl to ./helloworld/development.ini Recursing into docs Creating ./helloworld/docs/ Copying index.txt_tmpl to ./helloworld/docs/index.txt Copying ez_setup.py to ./helloworld/ez_setup.py Copying setup.cfg_tmpl to ./helloworld/setup.cfg Copying setup.py_tmpl to ./helloworld/setup.py Copying test.ini_tmpl to ./helloworld/test.ini Running /usr/bin/python setup.py egg_info
配置host监听地址
$ cd helloworld $ vim development.ini host = 0.0.0.0
启动服务
$ paster serve --reload development.ini
10.2.2. config/routing.py
url routing 做为静态化让所有后缀加上.html
(mydevenv)[neo@development helloworld]$ vim helloworld/config/routing.py map.connect('/{controller}/{action}.html') map.connect('/{controller}/{action}/{id}.html')
10.2.3. mako template
10.2.3.1. include
<%include file="header.html"/> hello world <%include file="footer.html"/>
传递参数
<%include file="toolbar.html" args="current_section='members', username='ed'"/>
10.2.3.2. inherit
<%inherit file="base.html"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论