摘要: 1. continue. 可以使用return。 $("***").each(function(){ if(a == b){ return; // continue } })2. break , 使用return false $("***").each(function(){ if(a == b){ return false; // break } }) 阅读全文
posted @ 2012-09-21 09:21 john2000 阅读(764) 评论(0) 推荐(0) 编辑
摘要: 环境: python + fastcgi + flup + webpy操作系统: Centos现象:nginx log的描述大概如下, /static/Image/**.png, /static/css/**.css permission denied. 分析: 1>使用webpy自带的server 运行,一切正常。 可以肯定程序没有问题。 2>检测目录, 文件权限。 目录大部分是755, 文件644。 可以排除 文件和目录没有访问权限。最后只能认为是nginx的配置文件。 google发现。 nginx下游一个user指令。 这个指令默认为noboby。 将nobody改为系统r 阅读全文
posted @ 2012-09-21 09:17 john2000 阅读(724) 评论(0) 推荐(0) 编辑
摘要: http://hi.baidu.com/tianhuimin/blog/item/8cfa0a2414425c27d5074237.htmlnginx中文件上传大小client_max_body_size的默认值为1M, 修改为需要的即可,如client_max_body_size 5M; 阅读全文
posted @ 2012-04-13 17:50 john2000 阅读(242) 评论(0) 推荐(0) 编辑
摘要: postgresql的默认最大连接数是200, 如果连接数超过200就会报 So many clients alreay. 当然你可以通过show max_connections;查看当前最大的连接数修改最大连接数, 最重要的就是要修改shmmax(Maximum size of shared memory segment (bytes))http://www.postgresql.org/docs/current/static/kernel-resources.html#SYSVIPC-PARAMETERS这里有讲解这里讲解都什么占用shm,(shared memory segment)ht 阅读全文
posted @ 2012-03-27 09:47 john2000 阅读(5194) 评论(0) 推荐(0) 编辑
摘要: 关于decorator的官方描述如下:(http://docs.python.org/glossary.html)decoratorA function returning another function, usually applied as a function transformation using the@wrappersyntax. Common examples fordecorators areclassmethod()andstaticmethod().Thedecoratorsyntax is merely syntactic sugar, the following t 阅读全文
posted @ 2012-03-27 09:35 john2000 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 有关python的__call__在官方文档上有这么一句解释 (http://docs.python.org/reference/datamodel.html?highlight=__call__#object.__call__)object.__call__(self[,args...])Called when the instance is “called” as a function; if this method is defined,x(arg1,arg2,...)is a shorthand forx.__call__(arg1,arg2,...).当把一个实例当作方法来调用的时候 阅读全文
posted @ 2012-03-27 09:19 john2000 阅读(1128) 评论(0) 推荐(0) 编辑
摘要: 判断一个callable对象是否是函数>>> import os>>> import types>>> >>> for item in dir(os): if isinstance(eval('.'.join(['os', item])), types.FunctionType): print item _execvpe_exists_get_exports_list_make_stat_result_make_statvfs_result_pickle_stat_result_pickle 阅读全文
posted @ 2011-06-24 10:35 john2000 阅读(365) 评论(0) 推荐(0) 编辑
摘要: 对于三目运算符(ternary operator),python可以用conditional expressions来替代如对于x<5?1:0可以用下面的方式来实现1 if x<5 else 0注: conditional expressions是在python 2.5之前引入的,所以以上代码仅适用于2.5以及之后的版本对于2.5之前的版本,可以用下面这种形式X<5 and 1 or 0对于switch,我们完全可以用dictionary来实现,看下面的例子>>> def switch(choice): return dict(enumerate(range 阅读全文
posted @ 2011-06-15 11:05 john2000 阅读(2872) 评论(0) 推荐(0) 编辑
摘要: 通过os.access(filename,mode):s.access(path, mode)¶Use the real uid/gid to test for access to path. Note that most operationswill use the effective uid/gid, therefore this routine can be used in asuid/sgid environment to test if the invoking user has the specified access topath. mode should be F_O 阅读全文
posted @ 2011-06-15 10:53 john2000 阅读(2299) 评论(0) 推荐(0) 编辑
摘要: http://www.lfd.uci.edu/~gohlke/pythonlibs/ 阅读全文
posted @ 2011-06-13 13:10 john2000 阅读(297) 评论(0) 推荐(0) 编辑