<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>豆花@垃圾熊 &#187; Python</title>
	<atom:link href="http://www.douhua.im/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.douhua.im</link>
	<description>Open Source、Python、Flex/ActionScritp、Linux、CouchDB、MongoDB和Cloud</description>
	<lastBuildDate>Thu, 26 Aug 2010 21:19:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Google Python Class Day 1-3</title>
		<link>http://www.douhua.im/2010/08/09/google-python-class-day-1-3/</link>
		<comments>http://www.douhua.im/2010/08/09/google-python-class-day-1-3/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 12:40:33 +0000</pubDate>
		<dc:creator>豆花&#38;垃圾熊</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.douhua.im/?p=489</guid>
		<description><![CDATA[Google Python Class Day 1-3 下载地址： http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.3.flv]]></description>
			<content:encoded><![CDATA[<p>Google Python Class Day 1-3</p>
<div id="flashcontent1686"><video controls='controls' width='470' height='320'>
<source src='http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.3.flv' type='video/mp4'>
</video>
</div>

<script type="text/javascript">
	swfobject.embedSWF('http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf', 'flashcontent1686', '470', '320', '10.0.0', 'http://www.douhua.im/wp-content/plugins/FMP-embed/expressinstall.swf', {src:'http%3A%2F%2Fwww.douhua.im%2Fdownloads%2Fgoogle.python.class%2FGoogle.Python.Class.Day.1.Part.3.flv', controlBarMode:'docked', controlBarAutoHide:'true', playButtonOverlay:'true', loop:'false', autoPlay:'false', streamType:'liveOrRecorded', scaleMode:'letterbox'}, {allowfullscreen:'true', allowscriptaccess:'always'})
</script>

<p>下载地址：<br />
<a href="http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.3.flv">http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.3.flv</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.douhua.im/2010/08/09/google-python-class-day-1-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.3.flv" length="144701119" type="video/x-flv" />
		</item>
		<item>
		<title>Google Python Class Day 1-2</title>
		<link>http://www.douhua.im/2010/08/09/google-python-class-day-1-2/</link>
		<comments>http://www.douhua.im/2010/08/09/google-python-class-day-1-2/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 12:34:39 +0000</pubDate>
		<dc:creator>豆花&#38;垃圾熊</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.douhua.im/?p=486</guid>
		<description><![CDATA[Google Python Class Day 1-2： 下载地址：http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.2.flv]]></description>
			<content:encoded><![CDATA[<p>Google Python Class Day 1-2：</p>
<div id="flashcontent1929"><video controls='controls' width='470' height='320'>
<source src='http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.2.flv' type='video/mp4'>
</video>
</div>

<script type="text/javascript">
	swfobject.embedSWF('http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf', 'flashcontent1929', '470', '320', '10.0.0', 'http://www.douhua.im/wp-content/plugins/FMP-embed/expressinstall.swf', {src:'http%3A%2F%2Fwww.douhua.im%2Fdownloads%2Fgoogle.python.class%2FGoogle.Python.Class.Day.1.Part.2.flv', controlBarMode:'docked', controlBarAutoHide:'true', playButtonOverlay:'true', loop:'false', autoPlay:'false', streamType:'liveOrRecorded', scaleMode:'letterbox'}, {allowfullscreen:'true', allowscriptaccess:'always'})
</script>

<p>下载地址：<a href="http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.2.flv">http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.2.flv</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.douhua.im/2010/08/09/google-python-class-day-1-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.douhua.im/downloads/google.python.class/Google.Python.Class.Day.1.Part.2.flv" length="175868713" type="video/x-flv" />
		</item>
		<item>
		<title>Google Python Class</title>
		<link>http://www.douhua.im/2010/03/23/google-python-class/</link>
		<comments>http://www.douhua.im/2010/03/23/google-python-class/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 17:03:17 +0000</pubDate>
		<dc:creator>豆花&#38;垃圾熊</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Google Python Class]]></category>

		<guid isPermaLink="false">http://www.douhua.im/?p=414</guid>
		<description><![CDATA[Google Python Class是Google组织的一系列学习Python的教程，包括很多视频和编程的练习，学习和使用Python的人一定不要错过。]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/edu/languages/google-python-class">Google Python Class</a>是Google组织的一系列学习Python的教程，包括很多视频和编程的练习，学习和使用Python的人一定不要错过。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.douhua.im/2010/03/23/google-python-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyAMF的Subversion 地址更换</title>
		<link>http://www.douhua.im/2010/03/04/pyamf-change-subversion-path/</link>
		<comments>http://www.douhua.im/2010/03/04/pyamf-change-subversion-path/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 11:49:44 +0000</pubDate>
		<dc:creator>豆花&#38;垃圾熊</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[PyAMF]]></category>

		<guid isPermaLink="false">http://www.douhua.im/?p=399</guid>
		<description><![CDATA[在更新PyAMF的时候发现总是出现bug： svn: Target path does not exist 到pyamf.org上去发现首页改版了，Subverion的地址也改了，新地址是： svn co http://svn.pyamf.org/trunk pyamf]]></description>
			<content:encoded><![CDATA[<p>在更新PyAMF的时候发现总是出现bug：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span>: Target path does not exist</pre></div></div>

<p>到pyamf.org上去发现首页改版了，Subverion的地址也改了，新地址是：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> http:<span style="color: #000000; font-weight: bold;">//</span>svn.pyamf.org<span style="color: #000000; font-weight: bold;">/</span>trunk pyamf</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.douhua.im/2010/03/04/pyamf-change-subversion-path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用PEP 8检查Python Coding风格</title>
		<link>http://www.douhua.im/2010/02/25/pep8-python-coding-style/</link>
		<comments>http://www.douhua.im/2010/02/25/pep8-python-coding-style/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 17:44:31 +0000</pubDate>
		<dc:creator>豆花&#38;垃圾熊</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[PEP 8]]></category>

		<guid isPermaLink="false">http://www.douhua.im/?p=377</guid>
		<description><![CDATA[今天才知道有个检查Python程序风格的工具：pep8。PEP8来源于Python官方的《Python Developers Guide》的第8章节：Style Guide for Python Code，主要讲述Python编码的统一风格，网上能搜到很多中文翻译版本。写了一段时间的Python程序，还真的没有仔细看过Python Developers Guide，平常一直都是翻阅《Learning Python》，要找个时间看看这个文档了。 PEP8的程序托管在github上，下载安装后可以运行pep8这个命令，参数就是要检查的Python文件，不符合PEP8规范的地方都会在输出信息里面列出来： optparse.py:69:11: E401 multiple imports on one line optparse.py:77:1: E302 expected 2 blank lines, found 1 optparse.py:88:5: E301 expected 1 blank line, found 0 optparse.py:222:34: W602 deprecated form of raising exception optparse.py:347:31: E211 whitespace before '(' optparse.py:357:17: E201 whitespace after '{' optparse.py:472:29: E221 multiple spaces [...]]]></description>
			<content:encoded><![CDATA[<p>今天才知道有个检查Python程序风格的工具：<strong>pep8</strong>。PEP8来源于Python官方的《<a href="http://www.python.org/dev/">Python Developers Guide</a>》的第8章节：<a href="http://www.python.org/dev/peps/pep-0008/">Style Guide for Python Code</a>，主要讲述Python编码的统一风格，网上能搜到很多中文翻译版本。写了一段时间的Python程序，还真的没有仔细看过<a href="http://www.python.org/dev/">Python Developers Guide</a>，平常一直都是翻阅《Learning Python》，要找个时间看看这个文档了。</p>
<p>PEP8的程序托管在<a href="http://github.com/jcrocholl/pep8/">github</a>上，下载安装后可以运行pep8这个命令，参数就是要检查的Python文件，不符合PEP8规范的地方都会在输出信息里面列出来：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">optparse.py:<span style="color: #000000;">69</span>:<span style="color: #000000;">11</span>: E401 multiple imports on one line
optparse.py:<span style="color: #000000;">77</span>:<span style="color: #000000;">1</span>: E302 expected <span style="color: #000000;">2</span> blank lines, found <span style="color: #000000;">1</span>
optparse.py:<span style="color: #000000;">88</span>:<span style="color: #000000;">5</span>: E301 expected <span style="color: #000000;">1</span> blank line, found <span style="color: #000000;">0</span>
optparse.py:<span style="color: #000000;">222</span>:<span style="color: #000000;">34</span>: W602 deprecated form of raising exception
optparse.py:<span style="color: #000000;">347</span>:<span style="color: #000000;">31</span>: E211 whitespace before <span style="color: #ff0000;">'('</span>
optparse.py:<span style="color: #000000;">357</span>:<span style="color: #000000;">17</span>: E201 whitespace after <span style="color: #ff0000;">'{'</span>
optparse.py:<span style="color: #000000;">472</span>:<span style="color: #000000;">29</span>: E221 multiple spaces before operator
optparse.py:<span style="color: #000000;">544</span>:<span style="color: #000000;">21</span>: W601 .has_key<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> is deprecated, use <span style="color: #ff0000;">'in'</span></pre></div></div>

<p>最好使用&#8211;show-pep8参数，它会在每个不符合规范的地方都加入解释。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.douhua.im/2010/02/25/pep8-python-coding-style/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>python-twitter 验证 Twitter用户名密码</title>
		<link>http://www.douhua.im/2010/02/14/python-twitter-verify-credentials/</link>
		<comments>http://www.douhua.im/2010/02/14/python-twitter-verify-credentials/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 13:57:57 +0000</pubDate>
		<dc:creator>豆花&#38;垃圾熊</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[python-twitter]]></category>
		<category><![CDATA[VerifyCredentials]]></category>

		<guid isPermaLink="false">http://www.douhua.im/?p=355</guid>
		<description><![CDATA[Twitter 的 API 提供一个验证用户的接口，如果验证用户名密码成功，返回用户的Profile信息。python-twitter也提供了封装，下面是个使用的例子， import simplejson import twitter &#160; USERNAME = 'xxxxxx' PASSWORD = 'xxxxxx' &#160; try: api = twitter.Api&#40;username = USERNAME, password = PASSWORD&#41; user = api.VerifyCredentials&#40;&#41; print 'Verify Credentials Success: %s' % user.name except: print 'Verify Credentials Error']]></description>
			<content:encoded><![CDATA[<p>Twitter 的 API 提供一个验证用户的接口，如果验证用户名密码成功，返回用户的Profile信息。python-twitter也提供了封装，下面是个使用的例子，</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">import simplejson
import twitter
&nbsp;
USERNAME = <span style="color: #ff0000;">'xxxxxx'</span>
PASSWORD = <span style="color: #ff0000;">'xxxxxx'</span>
&nbsp;
try:
    api = twitter.Api<span style="color: #7a0874; font-weight: bold;">&#40;</span>username = USERNAME, password = PASSWORD<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    user = api.VerifyCredentials<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    print <span style="color: #ff0000;">'Verify Credentials Success: %s'</span> <span style="color: #000000; font-weight: bold;">%</span> user.name
except:
    print <span style="color: #ff0000;">'Verify Credentials Error'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.douhua.im/2010/02/14/python-twitter-verify-credentials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python 使用 GData-Client-Python 库访问Youtube数据</title>
		<link>http://www.douhua.im/2010/02/04/gdata-python-youtube/</link>
		<comments>http://www.douhua.im/2010/02/04/gdata-python-youtube/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 12:30:40 +0000</pubDate>
		<dc:creator>豆花&#38;垃圾熊</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[GData]]></category>
		<category><![CDATA[Youtube]]></category>

		<guid isPermaLink="false">http://www.douhua.im/?p=336</guid>
		<description><![CDATA[使用Python和gdata-python-client就可以访问Google的诸多服务，下面的例子是访问Youtube.com视频的方法。在Youtube.com的API站点找到的： import gdata.youtube import gdata.youtube.service &#160; yt_service = gdata.youtube.service.YouTubeService&#40;&#41; entry = yt_service.GetYouTubeVideoEntry&#40;video_id='TGbwL8kSpEk'&#41; &#160; def PrintEntryDetails&#40;entry&#41;: print 'Video title: %s' % entry.media.title.text print 'Video published on: %s ' % entry.published.text print 'Video description: %s' % entry.media.description.text print 'Video category: %s' % entry.media.category&#91;0&#93;.text print 'Video tags: %s' % entry.media.keywords.text print 'Video watch page: %s' % entry.media.player.url print [...]]]></description>
			<content:encoded><![CDATA[<p>使用Python和gdata-python-client就可以访问Google的诸多服务，下面的例子是访问Youtube.com视频的方法。在Youtube.com的API站点找到的：</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> gdata.<span style="color: black;">youtube</span>
<span style="color: #ff7700;font-weight:bold;">import</span> gdata.<span style="color: black;">youtube</span>.<span style="color: black;">service</span>
&nbsp;
yt_service = gdata.<span style="color: black;">youtube</span>.<span style="color: black;">service</span>.<span style="color: black;">YouTubeService</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
entry = yt_service.<span style="color: black;">GetYouTubeVideoEntry</span><span style="color: black;">&#40;</span>video_id=<span style="color: #483d8b;">'TGbwL8kSpEk'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> PrintEntryDetails<span style="color: black;">&#40;</span>entry<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Video title: %s'</span> <span style="color: #66cc66;">%</span> entry.<span style="color: black;">media</span>.<span style="color: black;">title</span>.<span style="color: black;">text</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Video published on: %s '</span> <span style="color: #66cc66;">%</span> entry.<span style="color: black;">published</span>.<span style="color: black;">text</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Video description: %s'</span> <span style="color: #66cc66;">%</span> entry.<span style="color: black;">media</span>.<span style="color: black;">description</span>.<span style="color: black;">text</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Video category: %s'</span> <span style="color: #66cc66;">%</span> entry.<span style="color: black;">media</span>.<span style="color: black;">category</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">text</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Video tags: %s'</span> <span style="color: #66cc66;">%</span> entry.<span style="color: black;">media</span>.<span style="color: black;">keywords</span>.<span style="color: black;">text</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Video watch page: %s'</span> <span style="color: #66cc66;">%</span> entry.<span style="color: black;">media</span>.<span style="color: black;">player</span>.<span style="color: black;">url</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Video flash player URL: %s'</span> <span style="color: #66cc66;">%</span> entry.<span style="color: black;">GetSwfUrl</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Video duration: %s'</span> <span style="color: #66cc66;">%</span> entry.<span style="color: black;">media</span>.<span style="color: black;">duration</span>.<span style="color: black;">seconds</span>
&nbsp;
    <span style="color: #808080; font-style: italic;"># show alternate formats</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> alternate_format <span style="color: #ff7700;font-weight:bold;">in</span> entry.<span style="color: black;">media</span>.<span style="color: black;">content</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #483d8b;">'isDefault'</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> alternate_format.<span style="color: black;">extension_attributes</span>:
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Alternate format: %s | url: %s '</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>alternate_format.<span style="color: #008000;">type</span>, alternate_format.<span style="color: black;">url</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;"># show thumbnails</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> thumbnail <span style="color: #ff7700;font-weight:bold;">in</span> entry.<span style="color: black;">media</span>.<span style="color: black;">thumbnail</span>:
        urls = thumbnail.<span style="color: black;">url</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/'</span><span style="color: black;">&#41;</span>
        ids = urls<span style="color: black;">&#91;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>urls<span style="color: black;">&#41;</span> - <span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'.'</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> ids<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Thumbnail url: %s'</span> <span style="color: #66cc66;">%</span> thumbnail.<span style="color: black;">url</span>
&nbsp;
PrintEntryDetails<span style="color: black;">&#40;</span>entry<span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.douhua.im/2010/02/04/gdata-python-youtube/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[App Engine] Google App Engine 10个应用的限制</title>
		<link>http://www.douhua.im/2010/01/12/gaegoogle-app-engine-10-apps-limited/</link>
		<comments>http://www.douhua.im/2010/01/12/gaegoogle-app-engine-10-apps-limited/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 07:35:52 +0000</pubDate>
		<dc:creator>豆花&#38;垃圾熊</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[AppEngine]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.douhua.im/?p=171</guid>
		<description><![CDATA[Google App Engine默认是容许用户最多创建10个应用，如果你已经用完了10个怎么办？ Chinese 方式：申请更多的Google Account，为每个账户申请GAE。 American 方式：到邮件列表发个Email，说明自己的情况，请Google Support来处理。 今天在邮件列表里面见到一封这样的信，Google的Support人员在2天后为他增加了10个应用的限制。]]></description>
			<content:encoded><![CDATA[<p>Google App Engine默认是容许用户最多创建10个应用，如果你已经用完了10个怎么办？</p>
<p><strong>Chinese 方式：申请更多的Google Account，为每个账户申请GAE。</strong><br />
<strong>American 方式：到邮件列表发个Email，说明自己的情况，请Google Support来处理。</strong></p>
<p>今天在邮件列表里面见到一封这样的信，Google的Support人员在2天后为他增加了10个应用的限制。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.douhua.im/2010/01/12/gaegoogle-app-engine-10-apps-limited/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Django] settings.py 中设置访问 MySQL 数据库</title>
		<link>http://www.douhua.im/2010/01/10/django-settings-mysql-cnf/</link>
		<comments>http://www.douhua.im/2010/01/10/django-settings-mysql-cnf/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 16:31:16 +0000</pubDate>
		<dc:creator>豆花&#38;垃圾熊</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Django]]></category>

		<guid isPermaLink="false">http://www.douhua.im/?p=162</guid>
		<description><![CDATA[Django访问数据库的设置是在settings.py中写入数据库的engine、用户名和密码，默认的写法是： DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. DATABASE_NAME = 'xxx' # Or path to database file if using sqlite3. DATABASE_USER = 'root' # Not used with sqlite3. DATABASE_PASSWORD = 'xxx' # Not used with sqlite3. DATABASE_HOST = 'localhost' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = [...]]]></description>
			<content:encoded><![CDATA[<p>Django访问数据库的设置是在settings.py中写入数据库的engine、用户名和密码，默认的写法是：</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">DATABASE_ENGINE = <span style="color: #483d8b;">'mysql'</span> <span style="color: #808080; font-style: italic;"># 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. </span>
DATABASE_NAME = <span style="color: #483d8b;">'xxx'</span> <span style="color: #808080; font-style: italic;"># Or path to database file if using sqlite3. </span>
DATABASE_USER = <span style="color: #483d8b;">'root'</span> <span style="color: #808080; font-style: italic;"># Not used with sqlite3. </span>
DATABASE_PASSWORD = <span style="color: #483d8b;">'xxx'</span> <span style="color: #808080; font-style: italic;"># Not used with sqlite3. </span>
DATABASE_HOST = <span style="color: #483d8b;">'localhost'</span> <span style="color: #808080; font-style: italic;"># Set to empty string for localhost. Not used with sqlite3. </span>
DATABASE_PORT = <span style="color: #483d8b;">'3306'</span> <span style="color: #808080; font-style: italic;"># Set to empty string for default. Not used with sqlite3.</span></pre></div></div>

<p>数据库的关键信息都写在settings.py中，这样做是非常不安全的。现在可以在settings.py里面使用DATABASE项代替以上的配置项，username和password可以写在配置文件中。下面是把username和password放到MySQL数据库的配置文件中，由DATABASE项读取的示例：</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">DATABASES = <span style="color: black;">&#123;</span>
    <span style="color: #483d8b;">'default'</span>: <span style="color: black;">&#123;</span>
        <span style="color: #483d8b;">'ENGINE'</span>: <span style="color: #483d8b;">'django.db.backends.mysql'</span>,
        <span style="color: #483d8b;">'OPTIONS'</span>: <span style="color: black;">&#123;</span>
            <span style="color: #483d8b;">'read_default_file'</span>: <span style="color: #483d8b;">'/etc/mysql/my.cnf'</span>,
        <span style="color: black;">&#125;</span>,
    <span style="color: black;">&#125;</span>
<span style="color: black;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># my.cnf</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>client<span style="color: #7a0874; font-weight: bold;">&#93;</span>
database = xxx
user = xxx
password = xxxxxx
default-character-set = utf8</pre></div></div>

<p>也可以在DATABASES中加入NAME来指定数据库名，client中去除database选项，HOST和PORT这些也都可以写在my.cnf文件中。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.douhua.im/2010/01/10/django-settings-mysql-cnf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Google AppEngine] 中使用Flex实现Google Account SignIn/SignOut</title>
		<link>http://www.douhua.im/2010/01/04/appengine-flex-google-account-signin-signout/</link>
		<comments>http://www.douhua.im/2010/01/04/appengine-flex-google-account-signin-signout/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 16:09:20 +0000</pubDate>
		<dc:creator>豆花&#38;垃圾熊</dc:creator>
				<category><![CDATA[Flex&ActionScript&AIR]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[AppEngine]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Account]]></category>

		<guid isPermaLink="false">http://www.douhua.im/?p=141</guid>
		<description><![CDATA[在AppEngine中可以使用Google Account实现认证。如果使用Flex Application作为UI，使用按钮实现Sign In/Sign Out需要把URL通过HTML页面的FlashVars传递到Flex Application中。但是这个URL的值是几个HTTP地址经过&#038;符号拼接而成，在Flex里通过FlexGlobals.topLevelApplication.parameters读取的时候只能读取第一个&#038;符号前的地址。所以这个URL需要在Python代码里面进行URL encode，在Flex Application中URL decode。 Python代码： def get &#40;self&#41;: user = users.get_current_user&#40;&#41; #Check login user if user: sign = urllib2.quote&#40;users.create_logout_url&#40;'/openparty'&#41;&#41; else: sign = urllib2.quote&#40;users.create_login_url&#40;'/openparty'&#41;&#41; #Init template vars template_values = &#123; 'sign' : sign, &#125; Flex代码： var url : String = decodeURI&#40;FlexGlobals.topLevelApplication.parameters&#91;'sign'&#93;&#41;;]]></description>
			<content:encoded><![CDATA[<p>在AppEngine中可以使用Google Account实现认证。如果使用Flex Application作为UI，使用按钮实现Sign In/Sign Out需要把URL通过HTML页面的FlashVars传递到Flex Application中。但是这个URL的值是几个HTTP地址经过&#038;符号拼接而成，在Flex里通过<a href="http://www.douhua.im/2009/10/21/flex-4-flexglobals-toplevelapplication">FlexGlobals.topLevelApplication.parameters</a>读取的时候只能读取第一个&#038;符号前的地址。所以这个URL需要在Python代码里面进行URL encode，在Flex Application中URL decode。</p>
<p>Python代码：</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">    <span style="color: #ff7700;font-weight:bold;">def</span> get <span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #dc143c;">user</span> = users.<span style="color: black;">get_current_user</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #808080; font-style: italic;">#Check login user</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">user</span>:
            sign = <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">quote</span><span style="color: black;">&#40;</span>users.<span style="color: black;">create_logout_url</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/openparty'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            sign = <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">quote</span><span style="color: black;">&#40;</span>users.<span style="color: black;">create_login_url</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/openparty'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #808080; font-style: italic;">#Init template vars</span>
        template_values = <span style="color: black;">&#123;</span>
            <span style="color: #483d8b;">'sign'</span> : sign,
        <span style="color: black;">&#125;</span></pre></div></div>

<p>Flex代码：</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">url</span> : <span style="color: #0066CC;">String</span> = decodeURI<span style="color: #66cc66;">&#40;</span>FlexGlobals.<span style="color: #006600;">topLevelApplication</span>.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'sign'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.douhua.im/2010/01/04/appengine-flex-google-account-signin-signout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
