欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2, C++/F#/Lisp
Quixote
小 (已恢复222.13.209.80(讨论)的编辑至Allen的最后一个修订版本) |
|||
(未显示2个用户的12个中间版本) | |||
第1行: | 第1行: | ||
+ | <center>[[Image:parki-i-ogrody-680x100.jpg|天涯何处无芳草,何必单恋一只花了]]</center> | ||
+ | |||
Quixote is yet another framework for developing Web applications in Python. | Quixote is yet another framework for developing Web applications in Python. | ||
第21行: | 第23行: | ||
或 /usr/local/lib/python2.5/site-packages/quixote/server/ // 使用了 Python 2.5 | 或 /usr/local/lib/python2.5/site-packages/quixote/server/ // 使用了 Python 2.5 | ||
demo 被安装到 /usr/local/lib/python2.4/site-packages/quixote/demo/ | demo 被安装到 /usr/local/lib/python2.4/site-packages/quixote/demo/ | ||
+ | python demo/mini_demo.py | ||
+ | http://localhost:8080 | ||
python server/simple_server.py | python server/simple_server.py | ||
http://localhost:8080 | http://localhost:8080 | ||
第55行: | 第59行: | ||
LoadModule scgi_module /usr/local/lib/python2.3/site-packages/mod_scgi.so | LoadModule scgi_module /usr/local/lib/python2.3/site-packages/mod_scgi.so | ||
<Location "/"> | <Location "/"> | ||
− | + | SetHandler scgi-handler // Apache 2.0 need, Apache 1.3 don't need | |
+ | SCGIServer 1localost:3000 | ||
SCGIHandler On | SCGIHandler On | ||
</Location> | </Location> | ||
− | + | ||
==Quixote Sample== | ==Quixote Sample== | ||
touch miniqx.py | touch miniqx.py | ||
第88行: | 第93行: | ||
python minipx.py | python minipx.py | ||
http://192.168.1.3:8082 | http://192.168.1.3:8082 | ||
+ | ==Quixote Toolkit== | ||
+ | * Publisher: maps URLs to Python code | ||
+ | * HTTPRequest, HTTPResponse classes | ||
+ | * Web server interfaces for CGI, FastCGI, SCGI, mod_python | ||
+ | * [[Python Templating Language]] (optional) | ||
+ | * [[Quixote Form Framework|Form framework]] (optional) | ||
+ | |||
+ | [[How Quixote Works]] | ||
==核心原则== | ==核心原则== | ||
Quixote is built on four core principles: | Quixote is built on four core principles: | ||
第132行: | 第145行: | ||
==相关链接== | ==相关链接== | ||
*http://www.quixote.ca/ | *http://www.quixote.ca/ | ||
+ | *http://www.quixote.ca/talks/ | ||
+ | *Developing Web Applications with Quixote - http://www.amk.ca/talks/quixote | ||
*http://www.mems-exchange.org/software/quixote/ | *http://www.mems-exchange.org/software/quixote/ | ||
+ | *http://www.memsnet.org/ | ||
*http://quixote.python.ca/releases/ | *http://quixote.python.ca/releases/ | ||
+ | *http://download.huihoo.com/quixote | ||
+ | *http://docs.huihoo.com/quixote | ||
*http://www.amk.ca/ | *http://www.amk.ca/ | ||
*The MEMS Exchange Architecture - http://www.amk.ca/python/writing/mx-architecture/ | *The MEMS Exchange Architecture - http://www.amk.ca/python/writing/mx-architecture/ | ||
+ | *Support for Quixote and REST Etc - http://docs.huihoo.com/homepage/dkuhlman/quixote_index.html | ||
+ | |||
+ | {{comment}} | ||
− | [[Category: | + | [[Category:Framework]] |
+ | [[Category:Python]] |
2012年10月28日 (日) 03:50的最后版本
Quixote is yet another framework for developing Web applications in Python.
对于robust, quixote是经过大规模实际应用检验的, douban.com的主要动力就是它.
在放弃使用Zope后,MEMS Exchange 决定开发 Quixote
若使用 apache, 请事先安装 mod_python 或 mod_scgi
目录 |
[编辑] 在线演示
http://demo.huihoo.com/quixote
[编辑] 安装指南
获得 quixote http://quixote.python.ca/releases/Quixote-2.4.tar.gz tar zxvf Quixote-2.4.tar.gz cd Quixote-2.4 python -c "import os, quixote; print os.path.dirname(quixote.__file__)" // 检查是否已有quixote安装 python setup.py install // quixote 安装到 :/usr/lib/python2.3/site-packages/quixote 若出现 error: invalid Python installation: unable to open /usr/lib/python2.3/config/Makefile (No such file or directory) 请安装 #apt-get install python2.3-dev 或 /usr/local/lib/python2.4/site-packages/quixote/server/ // 使用了 Python 2.4 或 /usr/local/lib/python2.5/site-packages/quixote/server/ // 使用了 Python 2.5 demo 被安装到 /usr/local/lib/python2.4/site-packages/quixote/demo/ python demo/mini_demo.py http://localhost:8080 python server/simple_server.py http://localhost:8080 python server/simple_server.py --port 4000 http://localhost:4000
通过mod_python与Apache的整合
#apt-get install apache2-dev 安装 apxs2 , apxs 针对 Apache 1.x 获得 http://www.apache.org/dist/httpd/modpython/mod_python-3.2.10.tgz ./configure --with-apxs=/usr/bin/apxs2 make make install vi /etc/apache2/sites-enabled/000-default 相关细节: /usr/lib/python2.3/site-packages/quixote/server/mod_python_handler.py LoadModule python_module /usr/lib/apache2/modules/mod_python.so <LocationMatch "^/quixote(/|$)"> SetHandler python-program PythonHandler quixote.server.mod_python_handler PythonOption quixote-publisher-factory quixote.demo.create_publisher PythonInterpreter quixote.demo PythonDebug On </LocationMatch> /etc/init.d/apache2 restart http://localhost/quixote
Windows用户
cd Quixote-2.4 修改 setup.py build_extensions = True python setup.py build_ext --compiler=mingw32 install
通过scgi
http://www.mems-exchange.org/software/scgi/ python setup.py install LoadModule scgi_module /usr/local/lib/python2.3/site-packages/mod_scgi.so <Location "/"> SetHandler scgi-handler // Apache 2.0 need, Apache 1.3 don't need SCGIServer 1localost:3000 SCGIHandler On </Location>
[编辑] Quixote Sample
touch miniqx.py
#!/usr/bin/env python from quixote.publish import Publisher from quixote.directory import Directory class RootDirectory(Directory): _q_exports = [, 'hello'] def _q_index(self): return <html> <body> Simple Quixote Server A <a href="hello">link</a>.
</body> </html> def hello(self): return '<html><body>Hello world!
<a href="/">Home</a></body></html>'
def create_publisher(): return Publisher(RootDirectory(), display_exceptions='plain')
if __name__ == '__main__': from quixote.server.simple_server import run print 'creating demo listening on http://192.168.1.3:8082/' run(create_publisher, host='192.168.1.3', port=8082)
python minipx.py
http://192.168.1.3:8082
[编辑] Quixote Toolkit
- Publisher: maps URLs to Python code
- HTTPRequest, HTTPResponse classes
- Web server interfaces for CGI, FastCGI, SCGI, mod_python
- Python Templating Language (optional)
- Form framework (optional)
[编辑] 核心原则
Quixote is built on four core principles:
- Publishing function results: Quixote's main job is using a URL to look up a Python callable (e.g., a function or method) and put its results on the web.
- The URL is part of the user interface, and the organization of source code and URL-space should roughly correspond.
- Embedding HTML in Python is cleaner and easier than embedding Python in HTML. // 类似 Java Servlet
- No magic: when Quixote can't figure out what to do, it refuses to guess the programmer's intent, preferring to raise an exception instead.
[编辑] Web Interface
The web interface to SPLAT! is implemented in the splat.web package, with the following modules:
- splat.web.util (splat/web/util.ptl)
- splat.web.index (splat/web/index.ptl)
- splat.web.bug_ui (splat/web/bug_ui.ptl)
- splat.web.prefs (splat/web/prefs.ptl)
In fact, there are many useful analogies between a traditional filesystem-based web server (such as Apache) and Quixote's Python-centric way of building a web site.:
Filesystem (e.g., Apache) | Quixote |
directory | Python namespace (module, package, ...) |
file | Python callable object (function, method, ...) |
index.html | _q_index() |
file exists, is readable | callable object exists, is in _q_exports |
[编辑] 相关项目
[编辑] 成功应用
more apps : http://www.mems-exchange.org/software/quixote/apps.html
[编辑] 相关链接
- http://www.quixote.ca/
- http://www.quixote.ca/talks/
- Developing Web Applications with Quixote - http://www.amk.ca/talks/quixote
- http://www.mems-exchange.org/software/quixote/
- http://www.memsnet.org/
- http://quixote.python.ca/releases/
- http://download.huihoo.com/quixote
- http://docs.huihoo.com/quixote
- http://www.amk.ca/
- The MEMS Exchange Architecture - http://www.amk.ca/python/writing/mx-architecture/
- Support for Quixote and REST Etc - http://docs.huihoo.com/homepage/dkuhlman/quixote_index.html
<discussion>characters_max=300</discussion>