<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">博客园_251 - 观照无明</title><subtitle type="text">无明最自在，自在力所转</subtitle><id>http://feed.cnblogs.com/blog/u/8411/rss</id><updated>2011-07-28T02:50:51Z</updated><author><name>251</name><uri>http://www.cnblogs.com/itrust/</uri></author><generator>feed.cnblogs.com</generator><link rel="alternate" type="text/html" href="http://www.cnblogs.com/itrust/"/><link rel="self" type="application/atom+xml" href="http://feed.cnblogs.com/blog/u/8411/rss"/><entry><id>http://www.cnblogs.com/itrust/archive/2011/05/17/2048290.html</id><title type="text">IE9 + django开发版WEB服务器 不响应或Socket报错</title><summary type="text">IE9 + django开发版WEB服务器 不响应或Socket报错===================================================Exception happened during processing of request from ('127.0.0.1', 49710)Traceback (most recent call last): File "C:\Python26\Lib\SocketServer.py", line 283, in _handle_request_noblock self.process</summary><published>2011-05-16T16:27:00Z</published><updated>2011-05-16T16:27:00Z</updated><author><name>251</name><uri>http://www.cnblogs.com/itrust/</uri></author><link rel="alternate" href="http://www.cnblogs.com/itrust/archive/2011/05/17/2048290.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/itrust/archive/2011/05/17/2048290.html"/><content type="html">&lt;div&gt;&lt;span style="border-collapse: separate; color: #000000; font-family: Tahoma; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span style="border-collapse: separate; color: #000000; font-family: Tahoma; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span style="font-family: Simsun;"&gt;IE9 + django开发版WEB服务器 不响应或Socket报错&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="border-collapse: separate; color: #000000; font-family: Tahoma; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span style="font-family: Simsun;"&gt;===================================================&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="border-collapse: separate; color: #000000; font-family: Tahoma; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span style="font-family: Simsun;"&gt;Exception happened during processing of request from ('127.0.0.1', 49710)&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt;&amp;nbsp; File "C:\Python26\Lib\SocketServer.py", line 283, in _handle_request_noblock&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.process_request(request, client_address)&lt;br /&gt;&amp;nbsp; File "C:\Python26\Lib\SocketServer.py", line 309, in process_request&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.finish_request(request, client_address)&lt;br /&gt;&amp;nbsp; File "C:\Python26\Lib\SocketServer.py", line 322, in finish_request&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.RequestHandlerClass(request, client_address, self)&lt;br /&gt;&amp;nbsp; File "D:\Studio\ilo\lib\site-packages\django\core\servers\basehttp.py", line 5&lt;br /&gt;70, in __init__&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BaseHTTPRequestHandler.__init__(self, *args, **kwargs)&lt;br /&gt;&amp;nbsp; File "C:\Python26\Lib\SocketServer.py", line 617, in __init__&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.handle()&lt;br /&gt;&amp;nbsp; File "D:\Studio\ilo\lib\site-packages\django\core\servers\basehttp.py", line 6&lt;br /&gt;10, in handle&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.raw_requestline = self.rfile.readline()&lt;br /&gt;&amp;nbsp; File "C:\Python26\Lib\socket.py", line 444, in readline&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data = self._sock.recv(self._rbufsize)&lt;br /&gt;error: [Errno 10054]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="border-collapse: separate; color: #000000; font-family: Tahoma; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span style="font-family: Simsun;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="border-collapse: separate; color: #000000; font-family: Tahoma; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span style="font-family: Simsun;"&gt;解决方案&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="border-collapse: separate; color: #000000; font-family: Tahoma; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"&gt;&lt;span style="font-family: Simsun;"&gt;--------------------&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Simsun;" face="Simsun"&gt;指定IP地址运行&lt;/span&gt;&lt;span style="font-family: Simsun;"&gt;django开发版WEB服务器，不使用127.0.0.1, 如: python manage.py runserver 192.168.1.2:80&lt;/span&gt;&lt;/div&gt;&lt;img src="http://www.cnblogs.com/itrust/aggbug/2048290.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/itrust/archive/2011/05/17/2048290.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/itrust/archive/2011/04/29/2032348.html</id><title type="text">google chrome 下django用户登录失败的问题</title><summary type="text">问题： django做的网站，用chrome访问时，有50%的概率会发生用户登录失败，request.user依然是匿名用户的情况。Firefox没问题。分析：痛苦了半天，静下心分析原因，发现最后页面在登录重定位后，chrome在请求页面时没有提交session。具体的访问过程是这样：1 /accounts/login/ 返回 302 FOUND，响应头中Location指向 / , 返回sessionid2 / 返回301 MOVED PERMANENTLY, 响应头中Location指向 /myapp/， 未返回 sessionid3 /myapp/ 返回200 OK, 返回具体页面。这个</summary><published>2011-04-28T16:25:00Z</published><updated>2011-04-28T16:25:00Z</updated><author><name>251</name><uri>http://www.cnblogs.com/itrust/</uri></author><link rel="alternate" href="http://www.cnblogs.com/itrust/archive/2011/04/29/2032348.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/itrust/archive/2011/04/29/2032348.html"/><content type="html">&lt;p&gt;&lt;strong&gt;问题：&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;django做的网站，用chrome访问时，有50%的概率会发生用户登录失败，request.user依然是匿名用户的情况。Firefox没问题。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;分析：&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;痛苦了半天，静下心分析原因，发现最后页面在登录重定位后，chrome在请求页面时没有提交session。具体的访问过程是这样：&lt;/p&gt;&lt;p&gt;&lt;span style="color: #003366;"&gt;1 &amp;nbsp; /accounts/login/ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;返回 302 FOUND，响应头中Location指向 &amp;nbsp;/ , 返回sessionid&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: #003366;"&gt;2 &amp;nbsp; / &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;返回301 MOVED PERMANENTLY, 响应头中Location指向 &amp;nbsp;/myapp/， 未返回 sessionid&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: #003366;"&gt;3 &amp;nbsp; /myapp/ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 返回200 OK, 返回具体页面。&lt;/span&gt;&lt;/p&gt;&lt;p&gt;这个过程中Firefox记下了sessionid, 在第3步中提交了；而chrome未记录，在第三步中未提交，导致问题。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;解决：&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: #000000;"&gt;问题的关键在于不同浏览器处理两次重定位的不同（Firefox&lt;span style="color: #000080;"&gt;聪明&lt;/span&gt;的记下了302那次请求的会话ID，而chrome没有）， 之所以有两次重定位，是因为我在urls.py直接把 / 映射到了 /myapp/，而在login.html中设置 next="/"。 如果只重定位一次，在login.html中设置 next="/myapp/"，问题就迎刃而解了。&lt;/span&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/itrust/aggbug/2032348.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/itrust/archive/2011/04/29/2032348.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/itrust/archive/2010/05/31/1748358.html</id><title type="text">django 开发多语言网站</title><summary type="text">Technorati 标签: django,i18n,javascript,中文,多语言 django的国际化支持非常好也很易用，支持代码、模板和JS的国际化整体解决方法。特别是到了1.2版本加入了对于模板本地的 日期和数字的本地格式化，其国际化支持已经完善。   应用方法 首先需要修改settings.py: 1. TEMPLATE_CONTEXT_PROCESSORS 加...</summary><published>2010-05-31T08:48:00Z</published><updated>2010-05-31T08:48:00Z</updated><author><name>251</name><uri>http://www.cnblogs.com/itrust/</uri></author><link rel="alternate" href="http://www.cnblogs.com/itrust/archive/2010/05/31/1748358.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/itrust/archive/2010/05/31/1748358.html"/><content type="text">Technorati 标签: django,i18n,javascript,中文,多语言 django的国际化支持非常好也很易用，支持代码、模板和JS的国际化整体解决方法。特别是到了1.2版本加入了对于模板本地的 日期和数字的本地格式化，其国际化支持已经完善。   应用方法 首先需要修改settings.py: 1. TEMPLATE_CONTEXT_PROCESSORS 加...</content></entry><entry><id>http://www.cnblogs.com/itrust/archive/2010/05/27/1745342.html</id><title type="text">不愁男女比例不协调</title><summary type="text">我说：哦，还得的再取消一个 早表情很严肃的说：是啊，如果选婷婷，乐乐会不高兴；如果选乐乐，婷婷会不高兴，不好办啊 果和早在不“结婚”以后，去书店看到早喜欢的奥特曼以，执意要买一本送给早，她妈妈问：你不是现在和李腾结婚了么，为什么不送给李腾呢？ 果说：我还是送给早早吧，他爸爸可能会高兴 多可爱的小姑娘，可惜了，必须取消到只留一个。 补充一句妞妞的经典语录：早早是很男很难的男生，为为是个小男孩。 难以...</summary><published>2010-05-27T06:03:00Z</published><updated>2010-05-27T06:03:00Z</updated><author><name>251</name><uri>http://www.cnblogs.com/itrust/</uri></author><link rel="alternate" href="http://www.cnblogs.com/itrust/archive/2010/05/27/1745342.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/itrust/archive/2010/05/27/1745342.html"/><content type="text">我说：哦，还得的再取消一个 早表情很严肃的说：是啊，如果选婷婷，乐乐会不高兴；如果选乐乐，婷婷会不高兴，不好办啊 果和早在不“结婚”以后，去书店看到早喜欢的奥特曼以，执意要买一本送给早，她妈妈问：你不是现在和李腾结婚了么，为什么不送给李腾呢？ 果说：我还是送给早早吧，他爸爸可能会高兴 多可爱的小姑娘，可惜了，必须取消到只留一个。 补充一句妞妞的经典语录：早早是很男很难的男生，为为是个小男孩。 难以...</content></entry><entry><id>http://www.cnblogs.com/itrust/archive/2010/05/24/1742599.html</id><title type="text">Word文件如源码一样也可比较和合并</title><summary type="text">昨日无意中发现，原来Word文件也可以像我们合并源码文件一样被比较和合并，这就意味着Word文件的编辑也支持多人同时编辑，形成多个分支，然后将各个分支的修改合并到一个文件中去。虽然，没有源码合并那么强大，但也有极大的应用价值。合并的效果如何，请看例子： 烦请下载我的例子： Merge Word.rar 其中有两个版本，第二版做了修改、删除和添加内容的工作 打开其中的 V1 ，然后在菜单上选 &amp;ld...</summary><published>2010-05-24T03:14:00Z</published><updated>2010-05-24T03:14:00Z</updated><author><name>251</name><uri>http://www.cnblogs.com/itrust/</uri></author><link rel="alternate" href="http://www.cnblogs.com/itrust/archive/2010/05/24/1742599.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/itrust/archive/2010/05/24/1742599.html"/><content type="text">昨日无意中发现，原来Word文件也可以像我们合并源码文件一样被比较和合并，这就意味着Word文件的编辑也支持多人同时编辑，形成多个分支，然后将各个分支的修改合并到一个文件中去。虽然，没有源码合并那么强大，但也有极大的应用价值。合并的效果如何，请看例子： 烦请下载我的例子： Merge Word.rar 其中有两个版本，第二版做了修改、删除和添加内容的工作 打开其中的 V1 ，然后在菜单上选 &amp;ld...</content></entry><entry><id>http://www.cnblogs.com/itrust/archive/2010/05/14/1735185.html</id><title type="text">python 的字符编码和中文处理</title><summary type="text">字符串 python有两种字符串 byteString = "hello world! (in my default locale)" unicodeString = u"hello Unicode world!" 相互转换 1 s = "hello normal string" 2 u = unicode( s, "utf-8" ) 3 backToBytes = u.encode( "ut...</summary><published>2010-05-14T02:03:00Z</published><updated>2010-05-14T02:03:00Z</updated><author><name>251</name><uri>http://www.cnblogs.com/itrust/</uri></author><link rel="alternate" href="http://www.cnblogs.com/itrust/archive/2010/05/14/1735185.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/itrust/archive/2010/05/14/1735185.html"/><content type="text">字符串 python有两种字符串 byteString = "hello world! (in my default locale)" unicodeString = u"hello Unicode world!" 相互转换 1 s = "hello normal string" 2 u = unicode( s, "utf-8" ) 3 backToBytes = u.encode( "ut...</content></entry><entry><id>http://www.cnblogs.com/itrust/archive/2010/05/13/1734780.html</id><title type="text">djang 测试心得</title><summary type="text">突破test.py，弄个目录放测试案例 总所周知，django支持放在models.py中的doctest和tests.py，他们都要放在项目目录下。如果为了测试model, 使用doctest让测试挨着model的定义，而且也可方便得到文档，这可接受。但是tests.py放所有的测试案例严重不符合我的习惯，我喜欢把所有测试案例集中放在一个专门的目录中，而且一个文件一个TestCase。因此，考虑...</summary><published>2010-05-13T10:08:00Z</published><updated>2010-05-13T10:08:00Z</updated><author><name>251</name><uri>http://www.cnblogs.com/itrust/</uri></author><link rel="alternate" href="http://www.cnblogs.com/itrust/archive/2010/05/13/1734780.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/itrust/archive/2010/05/13/1734780.html"/><content type="text">突破test.py，弄个目录放测试案例 总所周知，django支持放在models.py中的doctest和tests.py，他们都要放在项目目录下。如果为了测试model, 使用doctest让测试挨着model的定义，而且也可方便得到文档，这可接受。但是tests.py放所有的测试案例严重不符合我的习惯，我喜欢把所有测试案例集中放在一个专门的目录中，而且一个文件一个TestCase。因此，考虑...</content></entry><entry><id>http://www.cnblogs.com/itrust/archive/2010/05/13/1734143.html</id><title type="text">my django development environment (virtualenv+pip+django)</title><summary type="text">Steps download and install Python download and install setuptool, please choose right setuptool version which matches python version make a virtualenv &gt; virtualenv yourenvname install pip &gt; easy...</summary><published>2010-05-12T16:11:00Z</published><updated>2010-05-12T16:11:00Z</updated><author><name>251</name><uri>http://www.cnblogs.com/itrust/</uri></author><link rel="alternate" href="http://www.cnblogs.com/itrust/archive/2010/05/13/1734143.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/itrust/archive/2010/05/13/1734143.html"/><content type="text">Steps download and install Python download and install setuptool, please choose right setuptool version which matches python version make a virtualenv &gt; virtualenv yourenvname install pip &gt; easy...</content></entry><entry><id>http://www.cnblogs.com/itrust/archive/2010/05/12/1733797.html</id><title type="text">nginx+fastcgi+django实践笔记</title><summary type="text">先看配置： server { listen 80; server_name localhost; access_log logs/access.log main; error_log logs/error.log warn; location / { fastcgi_pass 127.0.0.1:3033; include fastcgi_django.conf; } locat...</summary><published>2010-05-12T08:14:00Z</published><updated>2010-05-12T08:14:00Z</updated><author><name>251</name><uri>http://www.cnblogs.com/itrust/</uri></author><link rel="alternate" href="http://www.cnblogs.com/itrust/archive/2010/05/12/1733797.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/itrust/archive/2010/05/12/1733797.html"/><content type="text">先看配置： server { listen 80; server_name localhost; access_log logs/access.log main; error_log logs/error.log warn; location / { fastcgi_pass 127.0.0.1:3033; include fastcgi_django.conf; } locat...</content></entry><entry><id>http://www.cnblogs.com/itrust/archive/2010/05/12/1733760.html</id><title type="text">django 开发 - 小心模板文件的编码格式(utf-8)</title><summary type="text">遇到一个很神的问题，网站中有一页的样式总是不正确（整体内容偏下），历经千辛万苦才发现是由于模板文件的编码引起的。原来没注意这个问题，所有模板文件都保存为ANSI编码，这个单单鬼使神差的存成了UTF-8，而且其中有中文，因此导致这个问题。很具体的原因没想明白。吸取教训： django 缺省认为他处理的字符串和文件都是 utf-8, 因此如果你的模板文件不是utf-8, 你可设置FILE_CHARSE...</summary><published>2010-05-12T07:45:00Z</published><updated>2010-05-12T07:45:00Z</updated><author><name>251</name><uri>http://www.cnblogs.com/itrust/</uri></author><link rel="alternate" href="http://www.cnblogs.com/itrust/archive/2010/05/12/1733760.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/itrust/archive/2010/05/12/1733760.html"/><content type="text">遇到一个很神的问题，网站中有一页的样式总是不正确（整体内容偏下），历经千辛万苦才发现是由于模板文件的编码引起的。原来没注意这个问题，所有模板文件都保存为ANSI编码，这个单单鬼使神差的存成了UTF-8，而且其中有中文，因此导致这个问题。很具体的原因没想明白。吸取教训： django 缺省认为他处理的字符串和文件都是 utf-8, 因此如果你的模板文件不是utf-8, 你可设置FILE_CHARSE...</content></entry></feed>
