Quixote

来自开放百科 - 灰狐
(版本间的差异)
跳转到: 导航, 搜索
第68行: 第68行:
 
==成功应用==
 
==成功应用==
 
*http://douban.com
 
*http://douban.com
 +
*http://lwn.net/
 
*http://beta.u2m.cn/
 
*http://beta.u2m.cn/
 
+
more apps : http://www.mems-exchange.org/software/quixote/apps.html
 
==相关链接==
 
==相关链接==
 
*http://www.quixote.ca/
 
*http://www.quixote.ca/

2007年2月6日 (二) 15:38的版本

Quixote is yet another framework for developing Web applications in Python.

对于robust, quixote是经过大规模实际应用检验的, douban.com的主要动力就是它.

目录

在线演示

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 
或 /usr/local/lib/python2.4/site-packages/quixote/server/  // 使用了 Python 2.4
或 /usr/local/lib/python2.5/site-packages/quixote/server/ // 使用了 Python 2.5
python server/simple_server.py
http://localhost:8080

通过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

核心原则

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.:

Table 1
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

相关链接

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱