{人面不知何去处 桃花依旧笑春风}

Python Extension

Posted in Uncategorized by interma on 2013/02/28

希望掌握一下这个技能。

自己写了一个示例,将ul_sign包装为一个python扩展
https://github.com/interma/misc/tree/master/py_extension

interma@debian:~/git/misc/py_extension/ul_sign$ python
Python 2.7.3 (default, Jan  2 2013, 16:53:07) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ul_sign
>>> str="12334tret"
>>> ul_sign.creat_sign_fs64(str,len(str))
(73391337, 957628440)
interma@debian:~/git/misc/py_extension/ul_sign$ ./test 12334tret
12334tret:[73391337][957628440]

几个学习资料

官方手册:
http://docs.python.org/3/extending/extending.html
非常好的一个示例(from kdr2, :-)):
https://github.com/shuttler/nessDB/tree/v2.0/bindings/python

Tagged with:

WSGI

Posted in Uncategorized by interma on 2013/02/07

“WSGI本身是一个用来确保你的web应用能够与webserver进行对话,更重要的是,确保web应用之间能够一起配合工作的协议或约定”
http://zh.wikipedia.org/zh-cn/WSGI

缘由:
以前,如何选择合适的Web应用程序框架成为困扰Python初学者的一个问题,这是因为,一般而言,Web应用框架的选择将限制可用的Web服务器的选择,反之亦然。那时的Python应用程序通常是为CGI,FastCGI,mod_python中的一个而设计,甚至是为特定Web服务器的自定义的API接口而设计的。

要点:
WSGI有两方:“服务器”或“网关”一方,以及“应用程序”或“应用框架”一方。服务方调用应用方,提供环境信息,以及一个回调函数(提供给应用程序用来将消息头传递给服务器方),并接收Web内容作为返回值。即把服务器功能以 WSGI 接口暴露出来。
而WSGI中间件同时实现了API的两方,因此可以在WSGI服务和WSGI应用之间起调解作用:从WSGI服务器的角度来说,中间件扮演应用程序,而从应用程序的角度来说,中间件扮演服务器。

server=>[midware1]=>[midware2]=>app(framewrok),举例:apache=>mod_wsgi=>[flup]=>Django

答疑:
http://eishn.blog.163.com/blog/static/652318201011082044410/

讨论:
http://wiki.woodpecker.org.cn/moin/WSGI

toolkit:
http://werkzeug.pocoo.org/docs/tutorial/#module-werkzeug
https://github.com/mitsuhiko/werkzeug/blob/master/examples/shortly/shortly.py
example很好的展示了MVTD(model/view/template/dispatch)

Tagged with: ,