<?xml version="1.0" encoding="UTF-8"?><rss version="0.92">
<channel>
	<title>Oh Bug!</title>
	<link>http://ohbug.com</link>
	<description>Fun with Programming.</description>
	<lastBuildDate>Tue, 15 Jun 2010 02:20:14 +0000</lastBuildDate>
	<docs>http://backend.userland.com/rss092</docs>
	<language>en</language>
	<!-- generator="WordPress/3.0" -->

	<item>
		<title>Google App Engine 入门(1) 简介</title>
		<description><![CDATA[Google App Engine 是 Google 公司在2008年4月7日推出的一个开发、托管网络应用程序的云计算平台。它可以让你的网络应用程序在 Google 的基础架构上运行。 与 Google App Engine 类似的云计算平台还有 Amazon Web Service 和微软的 Azure 。Google App Engine 与他们不同的是 Google App Engine 给用户提供了一定的资源配额免费使用，当应用在免费配额无法负载的时候用户可以支付额外的费用以获得更多的CPU负载、带宽或是存储空间，用户只需要为使用超过免费配额的资源付费。 Google App Engine 最初只支持Python构建应用程序，2009年4月9日它开始支持 Java 构建应用程序。2010年5月20日 Google 发布 App Engine for Business，开始提供商用企业级云服务。 单个应用只能在Java 环境和 Python 环境之一中运行，App Engine 包括以下功能： 动态网络服务，提供对常用网络技术的完全支持 持久存储空间，支持查询、分类和事务 自动扩展和负载平衡 用于对用户进行身份验证和使用 Google 帐户发送电子邮件的 API 一种功能完整的本地开发环境（SDK），可以在您的计算机上模拟 Google App Engine [...]]]></description>
		<link>http://ohbug.com/archives/gae-intro.html</link>
			</item>
	<item>
		<title>GAE 查询1000条以外的记录</title>
		<description><![CDATA[fetch()方法一次只能获取或者偏移1000条记录，这样对于两千条以外的记录就无能为力了。要么利用数据明确的标识来解决，如时间日期、ID等；好在GAE开发团队又提供了cursor()和with_cursor()来获取和设置游标，下面是例子。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 offset = 1234 last_cursor = None while offset &#62;1000: q = Blobs.all&#40;&#41; q.order&#40;'-created_at'&#41; q.filter&#40;'deleted =',False&#41; q.fetch&#40;1000&#41; last_cursor = q.cursor&#40;&#41; offset -= 1000 &#160; q = Blobs.all&#40;&#41; q.order&#40;'-created_at'&#41; q.filter&#40;'deleted =',False&#41; if last_cursor: q.with_cursor&#40;last_cursor&#41; results = q.fetch&#40;page_size, offset=offset&#41; -EOF-]]></description>
		<link>http://ohbug.com/archives/gae-with_cursor.html</link>
			</item>
	<item>
		<title>A/B 向上取整</title>
		<description><![CDATA[要写一个分页函数，需要获得两个数的商的向上取整，而Python里没有整除和浮点数除法的分别，虽然说乘个1.0就然后直接比较整除和浮点数除法的结果可以解决这个问题，或者我直接调用math.ceil(x)来解决这个问题，可我又不想导入一个module。于是找到了下面的这个公式，可以取得两个数的商的向上取整： UP(A/B) = int((A+B-1)/B) 原文说A和B都需要大于1，其实不需要的，用带值法可以证明其实等于1就可以了。对于分页来说，这个公式完全满足条件，爽歪歪～ -EOF-]]></description>
		<link>http://ohbug.com/archives/ab-ceil.html</link>
			</item>
	<item>
		<title>在Win32上为Python2.5安装SSL1.15</title>
		<description><![CDATA[SSL for Python这个模块不像其它的模块直接下载下来执行setup.py install就安装好了，它需要编译再安装，过程遇到一些问题，这里记录一下如何安装成功的。 安装编译器MinGW 可以到MinGW网站下载GCC的win32版本 http://www.mingw.org/ 如果已经安装了VC6或者VS2003等编译器，可以略过此步骤。 获取依赖文件 OpenSSL libgw32c OpenSSL默认会安装在C:\Utils\GnuWin32,将libgw32c解压后也放在这个目录里。 获得ssl 1.15 Package代码 http://pypi.python.org/pypi/ssl/ 修改setup.py文件 如果OpenSSL安装路径不是默认的，就需要修改如下内容 if sys.platform == 'win32': &#160; # Assume the openssl libraries from GnuWin32 are installed in the # following location: gnuwin32_dir = os.environ.get&#40;&#34;GNUWIN32_DIR&#34;, r&#34;C:\Utils\GnuWin32&#34;&#41; 将C:\Utils\GnuWin32替换成实际的安装路径 修改cygwinccompiler.py文件 如果编译器版本不一致，还需要修改distutils\cygwinccompiler.py以跳过编译器版本检查，打开cygwinccompiler.py文件找到其中的如下内容(有两处)： result = re.search&#40;'(\d+\.\d+(\.\d+)*)',out_string&#41; 修改成 result = re.search&#40;'(\d+\.\d+(\.\d+)?)',out_string&#41; 开始编译吧 切换到ssl 1.15 Package解压目录下 [...]]]></description>
		<link>http://ohbug.com/archives/compile-ssl-for-python.html</link>
			</item>
	<item>
		<title>GAE图像API使用</title>
		<description><![CDATA[GAE中提供了Image服务用于简单的处理图片，下面这个类调用相关的API将数据库中的图片文件转换到指定大小(正方形)，同时给图片加水印，处理完成后输出图片。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 class PhotoviewHandler&#40;webapp.RequestHandler&#41;: def get&#40;self,img_id&#41;: p = db.get&#40;img_id&#41; if p: MIN_SIZE = 500 image = images.Image&#40;p.blob&#41; width [...]]]></description>
		<link>http://ohbug.com/archives/gae-image-api.html</link>
			</item>
	<item>
		<title>Python 风格指南</title>
		<description><![CDATA[一个典型模块的内部结构： 起始行 模块文档(文档字符串) 模块导入 (全局)变量定义 类定义(若有) 函数定义(若有) 主程序 示例代码： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #!/usr/bin/env python #coding:utf-8 &#160; &#34;this is a test module&#34; &#160; import sys import os &#160; debug = True &#160; class FooClass&#40;object&#41;: &#34;Foo class&#34; pass [...]]]></description>
		<link>http://ohbug.com/archives/python-style-guide.html</link>
			</item>
	<item>
		<title>你好,世界!</title>
		<description><![CDATA[#!/usr/bin/env python #coding:utf-8 &#160; def helloworld&#40;&#41;: &#34;Hello World! \ \nWelcome to my blog.&#34; print 'Nice to meet you!' if __name__ == '__main__': helloworld&#40;&#41; -EOF-]]></description>
		<link>http://ohbug.com/archives/hello-world.html</link>
			</item>
</channel>
</rss>
