很多公司都大量使用了python,其中有一些开发规范,code guidline, 通用组件,基础框架是可以共用的。
每个公司都自己搞一套, 太浪费人力,我想开一帖和大家讨论一下这些python基础设施的搭建。
原则是我们尽量不重新发明轮子,但开源组件这么多,也要有个挑选的过程和组合使用的过程,在这里讨论一下。
另一方面,有些开源组件虽然强大,但我们不能完全的驾驭它,或只使用其中很少的一部分,我们就可以考虑用python实现一个简单的轮子,可控性更强,最好不要超过300行代码。
diff -rup sphinx-2.0.4-release/api/sphinxapi.php 2.0.4/api/sphinxapi.php | |
--- sphinx-2.0.4-release/api/sphinxapi.php 2012-01-31 07:07:35.000000000 +0800 | |
+++ 2.0.4/api/sphinxapi.php 2012-03-30 16:39:25.000000000 +0800 | |
@@ -27,6 +27,7 @@ define ( "SEARCHD_COMMAND_KEYWORDS", 3 ) | |
define ( "SEARCHD_COMMAND_PERSIST", 4 ); | |
define ( "SEARCHD_COMMAND_STATUS", 5 ); | |
define ( "SEARCHD_COMMAND_FLUSHATTRS", 7 ); | |
+define ( "SEARCHD_COMMAND_DOCINFO", 9 ); | |
/// current client-side command implementation versions |
import re | |
# http://atomboy.isa-geek.com/plone/Members/acoil/programing/double-metaphone | |
from metaphone import dm as double_metaphone | |
# get the Redis connection | |
from jellybean.core import redis | |
import models | |
# Words which should not be indexed |
''' | |
redis_search.py | |
Written by Josiah Carlson July 3, 2010 | |
Released into the public domain. | |
This module implements a simple TF/IDF indexing and search algorithm using | |
Redis as a datastore server. The particular algorithm implemented uses the |
diff -rup sphinx-2.0.1-beta/src/searchd.cpp 2.0.1/src/searchd.cpp | |
--- sphinx-2.0.1-beta/src/searchd.cpp 2011-04-22 02:16:02.000000000 +0800 | |
+++ 2.0.1/src/searchd.cpp 2011-09-01 12:30:02.000000000 +0800 | |
@@ -439,7 +439,8 @@ enum SearchdCommand_e | |
SEARCHD_COMMAND_PERSIST = 4, | |
SEARCHD_COMMAND_STATUS = 5, | |
SEARCHD_COMMAND_FLUSHATTRS = 7, | |
- | |
+ SEARCHD_COMMAND_SEGMENT = 8, | |
+ SEARCHD_COMMAND_DOCINFO = 9, |
diff -rup sphinx-1.10-beta/src/searchd.cpp 1.10/src/searchd.cpp | |
--- sphinx-1.10-beta/src/searchd.cpp 2010-07-19 23:56:34.000000000 +0800 | |
+++ 1.10/src/searchd.cpp 2011-09-01 11:39:24.000000000 +0800 | |
@@ -353,6 +353,8 @@ enum SearchdCommand_e | |
SEARCHD_COMMAND_STATUS = 5, | |
SEARCHD_COMMAND_QUERY = 6, | |
SEARCHD_COMMAND_FLUSHATTRS = 7, | |
+ SEARCHD_COMMAND_SEGMENT = 8, | |
+ SEARCHD_COMMAND_DOCINFO = 9, | |
# -*- Encoding: utf-8 -*- | |
import base64 | |
import binascii | |
import cgi | |
import hashlib | |
import hmac | |
import logging | |
import time | |
import urllib | |
import urlparse |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta chraset="utf-8" /> | |
<style type="text/css"> | |
#kk{ | |
width:400px; height:400px; overflow: hidden; | |
} | |
#preview_wrapper{ | |
width:300px; height:300px; background-color:#CCC; overflow: hidden; |
# http://notmysock.org/blog/hacks/a-twisted-dns-story.html | |
# http://blog.inneoin.org/2009/11/i-used-twisted-to-create-dns-server.html | |
# twistd -y dns.py | |
import socket | |
from twisted.internet.protocol import Factory, Protocol | |
from twisted.internet import reactor | |
from twisted.names import dns | |
from twisted.names import client, server |
Consumer key: IQKbtAYlXLripLGPWd0HUA
Consumer secret: GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU
Consumer key: 3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys
Consumer key: CjulERsDeqhhjSme66ECg