<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>wolfg&#039;s Weblog &#187; Dev</title>
	<atom:link href="http://guoyong.me/category/dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://guoyong.me</link>
	<description>wolfg&#039;s journey with open source, linux, programming, sysadm ...</description>
	<lastBuildDate>Wed, 04 Apr 2012 12:42:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.5/cn/</creativeCommons:license>		<item>
		<title>使用Eclipse Memory Analyzer(MAT)解决Java Web应用故障</title>
		<link>http://guoyong.me/dev/solve-jvm-oom-problem-with-mat/</link>
		<comments>http://guoyong.me/dev/solve-jvm-oom-problem-with-mat/#comments</comments>
		<pubDate>Sun, 11 Mar 2012 14:54:11 +0000</pubDate>
		<dc:creator>guoyong</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[运维]]></category>
		<category><![CDATA[heap dump]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[mat]]></category>

		<guid isPermaLink="false">http://guoyong.me/?p=928</guid>
		<description><![CDATA[这周一我负责维护的一个系统突然出现故障，用户反映系统很慢，浏览器加载半天最后进了错误页面。登录到系统查看，发现系统负载很高，用sar命令进一步明确了是java进程在某一时刻后突然占据了大量CPU资源。查看应用日志，发现了OutOfMemory异常，然后使用jstat的gcutil确认JVM heap工作不正常，已经有上千次的full gc了。 用VisualGC或者jmap工具生成Headp dump文件，然后用MAT打开，生成内存泄露的分析报告，查找占用内存最大的对象并通过Thread call stack就可以定位导致问题出现的类和方法。 由于系统属旧系统，代码一直没有改动，显然是数据出了问题。最终发现是用户输入的格式不规范的数据，使得对数据做查找替换的一段代码不断地扩大1个字符串对象，导致内存消耗不断增长，gc频繁。 # sar # sar -P ALL 1 5 # jstat -gcutil &#60;pid_of_jvm&#62; 1000 # jmap -dump:format=b,file=HeapDump.hprof &#60;pid_of_jvm&#62; 参考: http://wiki.eclipse.org/index.php/MemoryAnalyzer]]></description>
			<content:encoded><![CDATA[<p>这周一我负责维护的一个系统突然出现故障，用户反映系统很慢，浏览器加载半天最后进了错误页面。登录到系统查看，发现系统负载很高，用sar命令进一步明确了是java进程在某一时刻后突然占据了大量CPU资源。查看应用日志，发现了OutOfMemory异常，然后使用jstat的gcutil确认JVM heap工作不正常，已经有上千次的full gc了。</p>
<p>用VisualGC或者jmap工具生成Headp dump文件，然后用MAT打开，生成内存泄露的分析报告，查找占用内存最大的对象并通过Thread call stack就可以定位导致问题出现的类和方法。</p>
<p>由于系统属旧系统，代码一直没有改动，显然是数据出了问题。最终发现是用户输入的格式不规范的数据，使得对数据做查找替换的一段代码不断地扩大1个字符串对象，导致内存消耗不断增长，gc频繁。</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># sar<br />
# sar -P ALL 1 5<br />
# jstat -gcutil &lt;pid_of_jvm&gt; 1000<br />
# jmap -dump:format=b,file=HeapDump.hprof &lt;pid_of_jvm&gt;</div></div>
<p>参考: <a href="http://wiki.eclipse.org/index.php/MemoryAnalyzer" target="_blank">http://wiki.eclipse.org/index.php/MemoryAnalyzer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/dev/solve-jvm-oom-problem-with-mat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Postgresql</title>
		<link>http://guoyong.me/linux/sysadm/using-postgresql/</link>
		<comments>http://guoyong.me/linux/sysadm/using-postgresql/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 05:56:45 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgresql]]></category>

		<guid isPermaLink="false">http://guoyong.org/?p=595</guid>
		<description><![CDATA[1. create tablespace $ mkdir -p /home/postgresql/data $ sudo chown -R postres:postres /home/postgresql/data $ sudo chmod -R og-rx /home/postgresql/data $ sudo su &#8211; postgres $ psql postgres=# create tablespace newspace location &#8216;/home/postgresql/data&#8217;; 2. move a database to this new tablespace &#8230; <a href="http://guoyong.me/linux/sysadm/using-postgresql/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>1. create tablespace<br />
$ mkdir -p /home/postgresql/data<br />
$ sudo chown -R postres:postres /home/postgresql/data<br />
$ sudo chmod -R og-rx /home/postgresql/data<br />
$ sudo su &#8211; postgres<br />
$ psql<br />
postgres=# create tablespace newspace location &#8216;/home/postgresql/data&#8217;;</p>
<p>2. move a database to this new tablespace<br />
use a php script from <a href="http://blog.lodeblomme.be/2008/03/15/move-a-postgresql-database-to-a-different-tablespace/">here</a> to generate sql<br />
$ sudo yum install php-pgsql<br />
$ ./generate-mv-db.php<br />
$ sudo su &#8211; postgres<br />
$ psql -d mydb -f migrate_localhost_mydb_newspace.sql</p>
<p>3. install postgis<br />
a. install proj4.7<br />
$ sudo yum install proj<br />
b. install geos 3.2.2<br />
$ tar xvjf geos-3.2.2.tar.bz2<br />
$ cd geos-3.2.2<br />
$ ./configure &#8211;prefix=/usr<br />
$ make &#038;&#038; sudo make install<br />
$ sudo ldconfig </p>
<blockquote><p> must do this, otherwise postgis will fail to locate libgeos_c.so.1
</p></blockquote>
<p>c. install postgis-1.5.1.tar.gz<br />
$ tar xvzf postgis-1.5.1.tar.gz<br />
$ cd postgis-1.5.1<br />
$ ./configure<br />
$ make &#038;&#038; sudo make install<br />
d. create a spatially-enabled database<br />
$ sudo su &#8211; postgres<br />
$ createdb postgis_template -U postgres;<br />
$ cd /usr/share/pgsql/contrib/postgis-1.5<br />
$ createlang plpgsql postgis_template<br />
$ psql -d postgis_template -f postgis.sql<br />
$ psql -d postgis_template -f spatial_ref_sys.sql</p>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/linux/sysadm/using-postgresql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>再谈使用Commons HttpClient产生大量CLOSE_WAIT</title>
		<link>http://guoyong.me/dev/%e5%86%8d%e8%b0%88%e4%bd%bf%e7%94%a8commons-httpclient%e4%ba%a7%e7%94%9f%e5%a4%a7%e9%87%8fclose_wait/</link>
		<comments>http://guoyong.me/dev/%e5%86%8d%e8%b0%88%e4%bd%bf%e7%94%a8commons-httpclient%e4%ba%a7%e7%94%9f%e5%a4%a7%e9%87%8fclose_wait/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 07:16:12 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[CLOSE_WAIT]]></category>
		<category><![CDATA[HttpClient]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[tcp]]></category>

		<guid isPermaLink="false">http://guoyong.org/?p=572</guid>
		<description><![CDATA[默认情况下(即用默认构造方法建立HttpClient对象)，httpMethod.releaseConnection()方法并不会关闭连接的Socket，目的是可以重用这个连接。网上有不少讨论： Re: CLOSE_WAIT, logging Re: [httpclient] CLOSE_WAIT sticking around Re: tcp connections left with CLOSE_WAIT apache httpclient与close_wait 这些讨论里提出了关闭Socket的方法，即在请求头里加上&#8221;Connection: close&#8221;，具体可见HTTP协议规范里的说明。 其实HttpClient 3.x 里还可以通过下面的方式建立HttpClient对象，来保证关闭Socket连接： HttpClient httpClient = new HttpClient(new SimpleHttpConnectionManager(true)); 具体可见HttpClient源码和API文档。 当然，使用HttpClient的多线程连接管理器时就不用这么做了。]]></description>
			<content:encoded><![CDATA[<p>默认情况下(即用默认构造方法建立HttpClient对象)，httpMethod.releaseConnection()方法并不会关闭连接的Socket，目的是可以重用这个连接。网上有不少讨论：</p>
<ul>
<li><a href="http://www.mail-archive.com/commons-httpclient-dev@jakarta.apache.org/msg04338.html">Re: CLOSE_WAIT, logging</a></li>
<li>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html">Re: [httpclient] CLOSE_WAIT sticking around</a></li>
<li>
<a href="http://www.mail-archive.com/httpclient-user@jakarta.apache.org/msg04467.html">Re: tcp connections left with CLOSE_WAIT</a></li>
<li><a href="http://swordinhand.javaeye.com/blog/149408">apache httpclient与close_wait</a></li>
</ul>
<p>这些讨论里提出了关闭Socket的方法，即在请求头里加上&#8221;Connection: close&#8221;，具体可见<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html">HTTP协议规范里的说明</a>。</p>
<p>其实HttpClient 3.x 里还可以通过下面的方式建立HttpClient对象，来保证关闭Socket连接：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Blue;">HttpClient</span><span style="color: Gray;"> </span><span style="color: Blue;">httpClient</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">HttpClient</span><span style="color: Olive;">(</span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">SimpleHttpConnectionManager</span><span style="color: Olive;">(</span><span style="color: Green;">true</span><span style="color: Olive;">))</span><span style="color: Gray;">;</span></li></ol></div>
<p>具体可见HttpClient源码和API文档。</p>
<p>当然，使用HttpClient的多线程连接管理器时就不用这么做了。</p>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/dev/%e5%86%8d%e8%b0%88%e4%bd%bf%e7%94%a8commons-httpclient%e4%ba%a7%e7%94%9f%e5%a4%a7%e9%87%8fclose_wait/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>再次遭遇大量CLOSE_WAIT</title>
		<link>http://guoyong.me/linux/sysadm/%e5%86%8d%e6%ac%a1%e9%81%ad%e9%81%87%e5%a4%a7%e9%87%8fclose_wait/</link>
		<comments>http://guoyong.me/linux/sysadm/%e5%86%8d%e6%ac%a1%e9%81%ad%e9%81%87%e5%a4%a7%e9%87%8fclose_wait/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 12:51:05 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[CLOSE_WAIT]]></category>
		<category><![CDATA[HttpClient]]></category>
		<category><![CDATA[jetty]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[tcp]]></category>

		<guid isPermaLink="false">http://guoyong.org/?p=543</guid>
		<description><![CDATA[今天下午线上的Jetty服务又停止响应了。不过与上次不同的是，日志里没有Too many open files的问题（看来ulimit设置管用了），看不出任何问题。于是用netstat检查网络连接，发现了大量CLOSE_WAIT状态的连接，而且都是连接到同一个IP地址。联想到程序里有调用外部网站服务的部分，检查这个IP，正是其中的一个服务。检查代码，发现开发人员使用Commons HttpClient时出了问题，居然忘记关闭连接了(method.releaseConnection();)！！后果就是对方关闭了连接，连接不断地变成CLOSE_WAIT状态，直到耗尽所有的网络资源，没法再建立连接了。 从这个教训看出，项目的研发管理真是没有到位啊！快速反复的需求、几乎可以忽略的设计、缺少代码走查、没有单元测试，怎能保证上线前发现这样的问题！]]></description>
			<content:encoded><![CDATA[<p>今天下午线上的Jetty服务又停止响应了。不过与上次不同的是，日志里没有Too many open files的问题（看来ulimit设置管用了），看不出任何问题。于是用netstat检查网络连接，发现了大量CLOSE_WAIT状态的连接，而且都是连接到同一个IP地址。联想到程序里有调用外部网站服务的部分，检查这个IP，正是其中的一个服务。检查代码，发现开发人员使用Commons HttpClient时出了问题，居然忘记关闭连接了(method.releaseConnection();)！！后果就是对方关闭了连接，连接不断地变成CLOSE_WAIT状态，直到耗尽所有的网络资源，没法再建立连接了。</p>
<p>从这个教训看出，项目的研发管理真是没有到位啊！快速反复的需求、几乎可以忽略的设计、缺少代码走查、没有单元测试，怎能保证上线前发现这样的问题！</p>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/linux/sysadm/%e5%86%8d%e6%ac%a1%e9%81%ad%e9%81%87%e5%a4%a7%e9%87%8fclose_wait/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>maven-eclipse-plugin v2.6与aspectj</title>
		<link>http://guoyong.me/dev/maven-eclipse-plugin-v26-with-aspectj/</link>
		<comments>http://guoyong.me/dev/maven-eclipse-plugin-v26-with-aspectj/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 06:17:47 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[maven-eclipse-plugin]]></category>

		<guid isPermaLink="false">http://guoyong.org/?p=365</guid>
		<description><![CDATA[最近一段时间以来，项目中使用maven-eclipse-plugin的eclipse:eclipse目标时比较恼人。pom里已经加入了aspectj的依赖，但生成的.classpath里却没有相应的classpathentry。 今天google到了解决办法，有两个： 1. 强制使用上个版本的maven-eclipse-plugin &#60;groupId&#62;org.apache.maven.plugins&#60;/groupId&#62;&#160; &#60;artifactId&#62;maven-eclipse-plugin&#60;/artifactId&#62;&#160; &#60;version&#62;2.5.1&#60;/version&#62;&#60;/plugin&#62; 2. 设置ajdtVersion为none &#60;groupId&#62;org.apache.maven.plugins&#60;/groupId&#62;&#160; &#60;artifactId&#62;maven-eclipse-plugin&#60;/artifactId&#62;&#160; &#60;configuration&#62;&#160;&#160; &#160;&#60;ajdtVersion&#62;none&#60;/ajdtVersion&#62;&#160; &#60;/configuration&#62;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#60;/plugin&#62;]]></description>
			<content:encoded><![CDATA[<p>最近一段时间以来，项目中使用maven-eclipse-plugin的eclipse:eclipse目标时比较恼人。pom里已经加入了aspectj的依赖，但生成的.classpath里却没有相应的classpathentry。</p>
<p>今天google到了解决办法，有两个：</p>
<p>1. 强制使用上个版本的maven-eclipse-plugin</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">groupId</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">org.apache.maven.plugins</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">groupId</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">artifactId</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">maven-eclipse-plugin</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">artifactId</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">version</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">2.5.1</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">version</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">plugin</span><span style="color: Olive;">&gt;</span></div></div>
<p>2. 设置ajdtVersion为none</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">groupId</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">org.apache.maven.plugins</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">groupId</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">artifactId</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">maven-eclipse-plugin</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">artifactId</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">configuration</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">ajdtVersion</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">none</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">ajdtVersion</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">configuration</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">plugin</span><span style="color: Olive;">&gt;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/dev/maven-eclipse-plugin-v26-with-aspectj/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BugFree与SVN整合脚本修改</title>
		<link>http://guoyong.me/dev/bugfree-with-the-svn-integration-script-modifications/</link>
		<comments>http://guoyong.me/dev/bugfree-with-the-svn-integration-script-modifications/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 07:56:00 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[bugfree]]></category>
		<category><![CDATA[scm]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://guoyong.org/?p=364</guid>
		<description><![CDATA[目前团队里使用subversion做版本控制，bugfree做缺陷管理。参照官方的做法实现了bugfree和svn的整合。 我为每个项目都设置了单独的svn仓库，这样在用viewvc浏览版本库时要指定root查询参数才能访问每个项目的代码库。因此我修改了bugfree官方提供的钩子脚本和向bugfree提交svn信息的php脚本，加入了对root查询参数的支持。具体改动见附件。 另外，为了维护方便，我在每个项目的hooks目录里做一个到钩子脚本的软链接，这样就只需维护一个钩子脚本文件了。]]></description>
			<content:encoded><![CDATA[<p>目前团队里使用subversion做版本控制，bugfree做缺陷管理。参照<a href="http://www.bugfree.org.cn/blog/?p=49">官方的做法</a>实现了bugfree和svn的整合。</p>
<p>我为每个项目都设置了单独的svn仓库，这样在用viewvc浏览版本库时要指定root查询参数才能访问每个项目的代码库。因此我修改了bugfree官方提供的钩子脚本和向bugfree提交svn信息的php脚本，加入了对root查询参数的支持。具体改动见<a href="http://guoyong.org/?dl=bugfree_svn.tar.gz">附件</a>。</p>
<p>另外，为了维护方便，我在每个项目的hooks目录里做一个到钩子脚本的软链接，这样就只需维护一个钩子脚本文件了。</p>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/dev/bugfree-with-the-svn-integration-script-modifications/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>解决Maven Jetty Plugin在Windows下的“文件锁定”问题</title>
		<link>http://guoyong.me/dev/jie-jue-maven-jetty-plugin-zai-windows-xia-di-wen-jian-suo-ding-wen-ti/</link>
		<comments>http://guoyong.me/dev/jie-jue-maven-jetty-plugin-zai-windows-xia-di-wen-jian-suo-ding-wen-ti/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 05:31:04 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jetty]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://guoyong.org/?p=360</guid>
		<description><![CDATA[使用Maven进行Java的web开发，Jetty Plugin是必不可缺的插件，可以极大的提到开发效率。但在Windows环境下会遇到静态文件（html、css、js）被锁定、无法即时更新的问题。要想更新这些文件，只能先停掉Jetty，保存修改，再启动Jetty，非常不方便。 解决办法是这样的： 1、从jetty.jar中解出webdefault.xml（位于org.mortbay.jetty.webapp包下）这个文件，把这个useFileMappedBuffer参数设为false &#60;init-param&#62;&#160;&#60;param-name&#62;useFileMappedBuffer&#60;/param-name&#62;&#160;&#60;!-- change to false --&#62;&#160;&#60;param-value&#62;true&#60;/param-value&#62;&#60;/init-param&#62; 2、把修改后的webdefault.xml文件跟pom.xml放在一起 3、修改pom.xml里的Jetty Plugin的配置，加入webdefault.xml ...&#60;plugin&#62;&#160;&#160; &#60;groupId&#62;org.mortbay.jetty&#60;/groupId&#62;&#160;&#160; &#60;artifactId&#62;maven-jetty-plugin&#60;/artifactId&#62;&#160;&#160; &#60;version&#62;6.1.7&#60;/version&#62;&#160;&#160; &#60;configuration&#62;&#160;&#160; &#160; &#60;contextPath&#62;/&#60;/contextPath&#62;&#160;&#160; &#160; &#60;webDefaultXml&#62;webdefault.xml&#60;/webDefaultXml&#62;&#160;&#160; &#160; ...&#160;&#160; &#160;&#60;/configuration&#62;&#160;&#160; &#160;...&#60;/plugin&#62;...]]></description>
			<content:encoded><![CDATA[<p>使用Maven进行Java的web开发，Jetty Plugin是必不可缺的插件，可以极大的提到开发效率。但在Windows环境下会遇到静态文件（html、css、js）被锁定、无法即时更新的问题。要想更新这些文件，只能先停掉Jetty，保存修改，再启动Jetty，非常不方便。<br />
解决办法是这样的：<br />
1、从jetty.jar中解出webdefault.xml（位于org.mortbay.jetty.webapp包下）这个文件，把这个useFileMappedBuffer参数设为false</p>
<div class="hl-surround"><div class="hl-main">&lt;init-param&gt;<br />&nbsp;&lt;param-name&gt;useFileMappedBuffer&lt;/param-name&gt;<br />&nbsp;&lt;!-- change to false --&gt;<br />&nbsp;&lt;param-value&gt;true&lt;/param-value&gt;<br />&lt;/init-param&gt;</div></div>
<p>2、把修改后的webdefault.xml文件跟pom.xml放在一起<br />
3、修改pom.xml里的Jetty Plugin的配置，加入<webDefaultXml>webdefault.xml</webDefaultXml></p>
<div class="hl-surround"><div class="hl-main">...<br />&lt;plugin&gt;<br />&nbsp;&nbsp; &lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;<br />&nbsp;&nbsp; &lt;artifactId&gt;maven-jetty-plugin&lt;/artifactId&gt;<br />&nbsp;&nbsp; &lt;version&gt;6.1.7&lt;/version&gt;<br />&nbsp;&nbsp; &lt;configuration&gt;<br />&nbsp;&nbsp; &nbsp; &lt;contextPath&gt;/&lt;/contextPath&gt;<br />&nbsp;&nbsp; &nbsp; &lt;webDefaultXml&gt;webdefault.xml&lt;/webDefaultXml&gt;<br />&nbsp;&nbsp; &nbsp; ...<br />&nbsp;&nbsp; &nbsp;&lt;/configuration&gt;<br />&nbsp;&nbsp; &nbsp;...<br />&lt;/plugin&gt;<br />...</div></div>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/dev/jie-jue-maven-jetty-plugin-zai-windows-xia-di-wen-jian-suo-ding-wen-ti/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Web页面自动打印PDF文件的实现</title>
		<link>http://guoyong.me/dev/web-e9-a1-b5-e9-9d-a2-e8-87-aa-e5-8a-a8-e6-89-93-e5-8d-b0pdf-e6-96-87-e4-bb-b6-e7-9a-84-e5-ae-9e-e7-8e-b0/</link>
		<comments>http://guoyong.me/dev/web-e9-a1-b5-e9-9d-a2-e8-87-aa-e5-8a-a8-e6-89-93-e5-8d-b0pdf-e6-96-87-e4-bb-b6-e7-9a-84-e5-ae-9e-e7-8e-b0/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 15:01:55 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[iText]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://guoyong.org/2008/02/29/350</guid>
		<description><![CDATA[借助iText和Adobe Acrobat的Javascript支持，可以实现PDF文档的自动打印（可以做到不显示打印对话框） ...... &#160; PdfReader&#160;reader = new PdfReader(pdfStream); [1] &#160; StringBuffer&#160;script = new StringBuffer(); [2] script.append(&#34;this.print({bUI: false,bSilent: true,bShrinkToFit: false});&#34;) &#160; .append(&#34;\r\nthis.closeDoc();&#34;); &#160; ByteArrayOutputStream&#160;bos = new ByteArrayOutputStream(pdfStream.length); try&#160;{ &#160; PdfStamper&#160;stamp = new PdfStamper(reader, bos); [3] &#160; stamp.setViewerPreferences(PdfWriter.HideMenubar&#160; &#160; &#160; &#124; PdfWriter.HideToolbar &#8230; <a href="http://guoyong.me/dev/web-e9-a1-b5-e9-9d-a2-e8-87-aa-e5-8a-a8-e6-89-93-e5-8d-b0pdf-e6-96-87-e4-bb-b6-e7-9a-84-e5-ae-9e-e7-8e-b0/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>借助iText和Adobe Acrobat的Javascript支持，可以实现PDF文档的自动打印（可以做到不显示打印对话框）</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Gray;">......</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">PdfReader</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">reader</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">PdfReader</span><span style="color: Olive;">(</span><span style="color: Blue;">pdfStream</span><span style="color: Olive;">)</span><span style="color: Gray;">; </span><span style="color: Olive;">[</span><span style="color: Maroon;">1</span><span style="color: Olive;">]</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">StringBuffer</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">script</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">StringBuffer</span><span style="color: Olive;">()</span><span style="color: Gray;">; </span><span style="color: Olive;">[</span><span style="color: Maroon;">2</span><span style="color: Olive;">]</span></li>
<li><span style="color: Blue;">script</span><span style="color: Gray;">.</span><span style="color: Blue;">append</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">this.print({bUI: false,bSilent: true,bShrinkToFit: false});</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span></li>
<li><span style="color: Gray;">&nbsp; .</span><span style="color: Blue;">append</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Navy;">\r\n</span><span style="color: Red;">this.closeDoc();</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">ByteArrayOutputStream</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">bos</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">ByteArrayOutputStream</span><span style="color: Olive;">(</span><span style="color: Blue;">pdfStream</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Green;">try</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">PdfStamper</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">stamp</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">PdfStamper</span><span style="color: Olive;">(</span><span style="color: Blue;">reader</span><span style="color: Gray;">, </span><span style="color: Blue;">bos</span><span style="color: Olive;">)</span><span style="color: Gray;">; </span><span style="color: Olive;">[</span><span style="color: Maroon;">3</span><span style="color: Olive;">]</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">stamp</span><span style="color: Gray;">.</span><span style="color: Blue;">setViewerPreferences</span><span style="color: Olive;">(</span><span style="color: Blue;">PdfWriter</span><span style="color: Gray;">.</span><span style="color: Blue;">HideMenubar</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; | </span><span style="color: Blue;">PdfWriter</span><span style="color: Gray;">.</span><span style="color: Blue;">HideToolbar</span><span style="color: Gray;"> | </span><span style="color: Blue;">PdfWriter</span><span style="color: Gray;">.</span><span style="color: Blue;">HideWindowUI</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">stamp</span><span style="color: Gray;">.</span><span style="color: Blue;">addJavaScript</span><span style="color: Olive;">(</span><span style="color: Blue;">script</span><span style="color: Gray;">.</span><span style="color: Blue;">toString</span><span style="color: Olive;">())</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">stamp</span><span style="color: Gray;">.</span><span style="color: Blue;">close</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">catch</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Blue;">DocumentException</span><span style="color: Gray;"> </span><span style="color: Blue;">e</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">logger</span><span style="color: Gray;">.</span><span style="color: Blue;">error</span><span style="color: Olive;">(</span><span style="color: Blue;">e</span><span style="color: Gray;">.</span><span style="color: Blue;">getMessage</span><span style="color: Olive;">()</span><span style="color: Gray;">, </span><span style="color: Blue;">e</span><span style="color: Gray;">.</span><span style="color: Blue;">getCause</span><span style="color: Olive;">())</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Green;">return</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">StreamingResolution</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">application/pdf</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,&nbsp; </span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">new</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">BufferedInputStream</span><span style="color: Olive;">(</span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">ByteArrayInputStream</span><span style="color: Olive;">(</span><span style="color: Blue;">bos</span><span style="color: Gray;">.</span><span style="color: Blue;">toByteArray</span><span style="color: Olive;">())))</span><span style="color: Gray;"> ;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">......</span></li></ol></div>
<p>代码说明：<br />
1、pdfStream是用iText生成的PDF文档字节流<br />
2、script是要加入到PDF文档里的Javascript代码。这段Javascript代码先调用PDF文档对象的print方法，然后用closeDoc方法关闭文档。print方法的参数指定了不要显示打印对话框，参数含义参考<a href="http://partners.adobe.com/public/developer/pdf/topic_js.html">Acrobat JavaScript Scripting Reference</a><br />
3、bos用来保存加入Javascript后的PDF文档字节流，它作为PdfStamper对象的输出流。PdfStamper对象调用addJavaScript方法将Javascript代码加入到PDF文档中。</p>
<p>Web页面嵌入PDF文档:</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">embed</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">application/pdf</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">src</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">/PrintPdf.action</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">1</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">height</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">1</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">embed</span><span style="color: Olive;">&gt;</span></li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/dev/web-e9-a1-b5-e9-9d-a2-e8-87-aa-e5-8a-a8-e6-89-93-e5-8d-b0pdf-e6-96-87-e4-bb-b6-e7-9a-84-e5-ae-9e-e7-8e-b0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>发布jar包到自己设立的Maven Repository</title>
		<link>http://guoyong.me/dev/%e5%8f%91%e5%b8%83jar%e5%8c%85%e5%88%b0%e8%87%aa%e5%b7%b1%e7%9a%84repository/</link>
		<comments>http://guoyong.me/dev/%e5%8f%91%e5%b8%83jar%e5%8c%85%e5%88%b0%e8%87%aa%e5%b7%b1%e7%9a%84repository/#comments</comments>
		<pubDate>Sat, 08 Dec 2007 07:28:47 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://guoyong.org/2007/12/08/348</guid>
		<description><![CDATA[使用Artifactiry为自己的开发团队设立了repository镜像。有时需要把本地的一些第三方的jar包发布到服务器，使用maven-deploy-plugin的deploy:deploy-file目标可以完成这个任务。 比如，要发布jta的jar包jta-1.0.1B.jar $ mvn deploy:deploy-file -DgroupId=javax.transaction \&#160;&#160; -DartifactId=jta \&#160;&#160; -Dversion=1.0.1B \&#160;&#160; -Dpackaging=jar \&#160;&#160; -Dfile=~/.m2/repository/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar \&#160;&#160; -DrepositoryId=central \&#160;&#160; -Durl=http://host.of.your.repository[:port]/artifactory/ibiblio@repo 说明： repositoryId在工程的pom文件里设置 url由Artifactiry的配置决定，注意不能使用virtual repository的地址 如果远程repository需要身份验证，用户名和密码需要在maven的settings.xml里设置 参考: http://maven.apache.org/guides/mini/guide-deploying-3rd-party-jars.html http://www.jfrog.org/sites/artifactory/latest/import.html]]></description>
			<content:encoded><![CDATA[<p>使用Artifactiry为自己的开发团队设立了repository镜像。有时需要把本地的一些第三方的jar包发布到服务器，使用maven-deploy-plugin的deploy:deploy-file目标可以完成这个任务。</p>
<p>比如，要发布jta的jar包jta-1.0.1B.jar</p>
<div class="hl-surround"><div class="hl-main">$ mvn deploy:deploy-file -DgroupId=javax.transaction \<br />&nbsp;&nbsp; -DartifactId=jta \<br />&nbsp;&nbsp; -Dversion=1.0.1B \<br />&nbsp;&nbsp; -Dpackaging=jar \<br />&nbsp;&nbsp; -Dfile=~/.m2/repository/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar \<br />&nbsp;&nbsp; -DrepositoryId=central \<br />&nbsp;&nbsp; -Durl=http://host.of.your.repository[:port]/artifactory/ibiblio@repo</div></div>
<p>说明：</p>
<ul>
<li>repositoryId在工程的pom文件里设置</li>
<li>url由Artifactiry的配置决定，注意不能使用virtual repository的地址</li>
<li>如果远程repository需要身份验证，用户名和密码需要在maven的settings.xml里设置</li>
</ul>
<p>参考: </p>
<ul>
<li> http://maven.apache.org/guides/mini/guide-deploying-3rd-party-jars.html </li>
<li> http://www.jfrog.org/sites/artifactory/latest/import.html </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/dev/%e5%8f%91%e5%b8%83jar%e5%8c%85%e5%88%b0%e8%87%aa%e5%b7%b1%e7%9a%84repository/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TurboGears开发笔记 (1)</title>
		<link>http://guoyong.me/dev/turbogear%e5%bc%80%e5%8f%91%e7%ac%94%e8%ae%b0-1/</link>
		<comments>http://guoyong.me/dev/turbogear%e5%bc%80%e5%8f%91%e7%ac%94%e8%ae%b0-1/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 05:38:09 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[turbogears]]></category>

		<guid isPermaLink="false">http://guoyong.org/2007/10/04/344</guid>
		<description><![CDATA[1. 使用MySQL数据库 1.1 使用UTF-8字符集 sqlobject.dburi=&#34;mysql://root:@localhost:3306/dbname?sqlobject_encoding=utf-8&#38;read_default_file=my.cnf&#34; 同时，my.cnf里在client一节加入 default-character-set = utf8 1.2 使用InnoDB类型的表 修改my.cnf，mysqld一节加入 default-storage-engine=INNODB 1.3 自身外键关联 使用InnoDB类型的表，tg-admin sql drop 时会遇到由于外键约束而无法删除的问题，可以改用MyISAM类型的表。tg-admin sql create时会有警告： Warning: a circular reference was detected in the model. Unable to sort the classes by dependency: they will be &#8230; <a href="http://guoyong.me/dev/turbogear%e5%bc%80%e5%8f%91%e7%ac%94%e8%ae%b0-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>1. 使用MySQL数据库</p>
<p>1.1 使用UTF-8字符集</p>
<div class="hl-surround"><div class="hl-main">sqlobject.dburi=&quot;mysql://root:@localhost:3306/dbname?sqlobject_encoding=utf-8&amp;read_default_file=my.cnf&quot;</div></div>
<p>同时，my.cnf里在client一节加入  default-character-set = utf8</p>
<p>1.2 使用InnoDB类型的表<br />
修改my.cnf，mysqld一节加入 default-storage-engine=INNODB</p>
<p>1.3 自身外键关联<br />
使用InnoDB类型的表，tg-admin sql drop 时会遇到由于外键约束而无法删除的问题，可以改用MyISAM类型的表。tg-admin sql create时会有警告：</p>
<div class="hl-surround"><div class="hl-main">Warning: a circular reference was detected in the model. Unable to sort the classes by dependency: they will be treated in alphabetic order. This may or may not work depending on your database backend. The error was:<br />Found a circular reference: ......</div></div>
<p>2. SQLObject</p>
<p>2.1 MultipleJoin最好指定joinColumn</p>
<p>3. Kid模板</p>
<p>3.1 用defined(varname) 可以判断一个变量是否存在于模板中，value_of则可以指定变量不存在时的默认值</p>
<p>3.2 results.count()可以得到查询结果集的大小</p>
<p>3.3 根据条件输出不同的内容 ${condition and &#8216;a&#8217; or &#8216;b&#8217;}<br />
比如交替表格中行的背景色</p>
<div class="hl-surround"><div class="hl-main">&lt;tr py:for=&quot;i, row in enumerate(rows)&quot; class=&quot;${i%2==0 and 'odd' or 'even'}&quot;&gt;<br />...<br />&lt;/tr&gt;</div></div>
<p>在select的option标签里输入selected属性</p>
<div class="hl-surround"><div class="hl-main">...<br />&lt;option value=&quot;...&quot; selected=&quot;${condition and 'selected' or None}&quot;&gt;... &lt;/option&gt;<br />...</div></div>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/dev/turbogear%e5%bc%80%e5%8f%91%e7%ac%94%e8%ae%b0-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows下mysql命令行工具插入和显示中文数据</title>
		<link>http://guoyong.me/dev/windows%e4%b8%8bmysql%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%b7%a5%e5%85%b7%e6%8f%92%e5%85%a5%e5%92%8c%e6%98%be%e7%a4%ba%e4%b8%ad%e6%96%87%e6%95%b0%e6%8d%ae/</link>
		<comments>http://guoyong.me/dev/windows%e4%b8%8bmysql%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%b7%a5%e5%85%b7%e6%8f%92%e5%85%a5%e5%92%8c%e6%98%be%e7%a4%ba%e4%b8%ad%e6%96%87%e6%95%b0%e6%8d%ae/#comments</comments>
		<pubDate>Thu, 17 May 2007 17:33:00 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://guoyong.org/2007/05/18/322</guid>
		<description><![CDATA[my.ini里client和mysqld都设置了default-character-set=utf8 数据库和表的默认字符集也都是utf8，用MySQL Query Browser工具插入和查询中文输入没有问题，但直接在命令提示符里用mysql工具插入和查询有中文乱码。 与 http://www.javaworld.com.tw/jute/post/view?bid=21&#038;id=128513&#038;sty=1&#038;tpg=1&#038;age=0 里说的一样，好像win下mysql命令行工具不认。 解决办法： 插入数据前，set names utf8; 执行查询前，set name gbk;]]></description>
			<content:encoded><![CDATA[<p>my.ini里client和mysqld都设置了default-character-set=utf8<br />
数据库和表的默认字符集也都是utf8，用MySQL Query Browser工具插入和查询中文输入没有问题，但直接在命令提示符里用mysql工具插入和查询有中文乱码。</p>
<p>与 http://www.javaworld.com.tw/jute/post/view?bid=21&#038;id=128513&#038;sty=1&#038;tpg=1&#038;age=0 里说的一样，好像win下mysql命令行工具不认。</p>
<p>解决办法：<br />
插入数据前，set names utf8;<br />
执行查询前，set name gbk;</p>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/dev/windows%e4%b8%8bmysql%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%b7%a5%e5%85%b7%e6%8f%92%e5%85%a5%e5%92%8c%e6%98%be%e7%a4%ba%e4%b8%ad%e6%96%87%e6%95%b0%e6%8d%ae/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>EasyEclipse的console中文乱码问题的解决</title>
		<link>http://guoyong.me/dev/easyeclipse%e7%9a%84console%e4%b8%ad%e6%96%87%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98%e7%9a%84%e8%a7%a3%e5%86%b3/</link>
		<comments>http://guoyong.me/dev/easyeclipse%e7%9a%84console%e4%b8%ad%e6%96%87%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98%e7%9a%84%e8%a7%a3%e5%86%b3/#comments</comments>
		<pubDate>Mon, 14 May 2007 16:49:59 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://guoyong.org/2007/05/15/321</guid>
		<description><![CDATA[EasyEclipse的console中输出中文是乱码，原因是它自带的jre不是多语言版本，从多语言版本的JDK里复制charsets.jar文件到%Easy_Eclipse_Home%\jre\jre\lib目录下，重新启动一下EasyEclipse就好了。]]></description>
			<content:encoded><![CDATA[<p>EasyEclipse的console中输出中文是乱码，原因是它自带的jre不是多语言版本，从多语言版本的JDK里复制charsets.jar文件到%Easy_Eclipse_Home%\jre\jre\lib目录下，重新启动一下EasyEclipse就好了。</p>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/dev/easyeclipse%e7%9a%84console%e4%b8%ad%e6%96%87%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98%e7%9a%84%e8%a7%a3%e5%86%b3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows XP下安装MySQL遇到的两个问题</title>
		<link>http://guoyong.me/dev/windows-xp%e4%b8%8b%e5%ae%89%e8%a3%85mysql%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%a4%e4%b8%aa%e9%97%ae%e9%a2%98/</link>
		<comments>http://guoyong.me/dev/windows-xp%e4%b8%8b%e5%ae%89%e8%a3%85mysql%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%a4%e4%b8%aa%e9%97%ae%e9%a2%98/#comments</comments>
		<pubDate>Mon, 14 May 2007 16:39:50 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://guoyong.org/2007/05/15/320</guid>
		<description><![CDATA[原来的安装用的是直接解压zip包的方式，安装情况如下： 1. 安装目录为C:\mysql-4.1.22-win32 2. my.ini从my-medium.ini修改而来，放在了C:\WINDOWS下 3. 安装Windows服务用的命令是 mysqld-nt &#8211;install 4. net start MySQL启动服务没有问题 但用MySQL Administrator工具连接时总是先弹出一个对话框，报告 Either the server service or the configuration file could not be found. Startup variables and service section are therefore disalbed. 点“确定”后才进入主界面，正如它所说，Service Control和Startup Variables功能都被禁用了，界面上有红色的提示信息 This section &#8230; <a href="http://guoyong.me/dev/windows-xp%e4%b8%8b%e5%ae%89%e8%a3%85mysql%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%a4%e4%b8%aa%e9%97%ae%e9%a2%98/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>原来的安装用的是直接解压zip包的方式，安装情况如下：<br />
1. 安装目录为C:\mysql-4.1.22-win32<br />
2. my.ini从my-medium.ini修改而来，放在了C:\WINDOWS下<br />
3. 安装Windows服务用的命令是 mysqld-nt &#8211;install<br />
4. net start MySQL启动服务没有问题</p>
<p>但用MySQL Administrator工具连接时总是先弹出一个对话框，报告</p>
<div class="hl-surround"><div class="hl-main">Either the server service or the configuration file could not be found. Startup variables and service section are therefore disalbed.</div></div>
<p>点“确定”后才进入主界面，正如它所说，Service Control和Startup Variables功能都被禁用了，界面上有红色的提示信息</p>
<div class="hl-surround"><div class="hl-main">This section is only available when connected to localhost.</div></div>
<p>换用msi安装包，重新安装MySQL，目录还是选择C:\mysql-4.1.22-win32（除了data目录之外，其他目录都已删除），最后配置实例时出现无法启动服务的问题。尝试逐个关闭my.ini中选项的方法，试验到底是那个选项导致不能启动。最后发现是innodb_log_file_size这个选项的问题。原来实际的log文件ib_logfile0和ib_logfile1的大小是5M，是由刚才的那个my.ini（即有zip包中my-medium.ini手工修改而来的）指定的，而现在的my.ini（由MySQL Server Instance Config Wizard生成）中同样的选项指定的却是17M，结果导致MySQL无法启动。解决办法是要么删除原来的那两个log文件，要么修改innodb_log_file_size。</p>
<p>现在可以正常启动MySQL服务，MySQL Administrator也可以正常使用。在注册表里查看MySQL Server Instance Config Wizard生成的MySQL服务，发现ImagePath的值是</p>
<div class="hl-surround"><div class="hl-main">C:\mysql-4.1.22-win32\bin\mysqld-nt --defaults-file=C:\mysql-4.1.22-win32\my.ini MySQL</div></div>
<p>说明之前MySQL Administrator报错的原因是服务由mysqld-nt &#8211;install命令创建，导致它找不到my.ini。</p>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/dev/windows-xp%e4%b8%8b%e5%ae%89%e8%a3%85mysql%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%a4%e4%b8%aa%e9%97%ae%e9%a2%98/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyGTK里取得一个xpm图标的灰度图</title>
		<link>http://guoyong.me/python/pygtk%e9%87%8c%e5%8f%96%e5%be%97%e4%b8%80%e4%b8%aaxpm%e5%9b%be%e6%a0%87%e7%9a%84%e7%81%b0%e5%ba%a6%e5%9b%be/</link>
		<comments>http://guoyong.me/python/pygtk%e9%87%8c%e5%8f%96%e5%be%97%e4%b8%80%e4%b8%aaxpm%e5%9b%be%e6%a0%87%e7%9a%84%e7%81%b0%e5%ba%a6%e5%9b%be/#comments</comments>
		<pubDate>Wed, 18 Apr 2007 13:47:14 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[pygtk]]></category>

		<guid isPermaLink="false">http://guoyong.org/2007/04/18/313</guid>
		<description><![CDATA[最近用PyMaemo写一个N800上跑的程序时用到的： self.mote_pixbuf = gtk.gdk.pixbuf_new_from_xpm_data(MOTE_PIXMAP) self.mote_gray_pixbuf = self.mote_pixbuf.copy() self.mote_pixbuf.saturate_and_pixelate(self.mote_gray_pixbuf, 0.0, True)]]></description>
			<content:encoded><![CDATA[<p>最近用PyMaemo写一个N800上跑的程序时用到的：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">mote_pixbuf</span><span style="color: Gray;"> = </span><span style="color: Blue;">gtk</span><span style="color: Gray;">.</span><span style="color: Blue;">gdk</span><span style="color: Gray;">.</span><span style="color: Blue;">pixbuf_new_from_xpm_data</span><span style="color: Olive;">(</span><span style="color: Blue;">MOTE_PIXMAP</span><span style="color: Olive;">)</span></li>
<li><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">mote_gray_pixbuf</span><span style="color: Gray;"> = </span><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">mote_pixbuf</span><span style="color: Gray;">.</span><span style="color: Blue;">copy</span><span style="color: Olive;">()</span></li>
<li><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">mote_pixbuf</span><span style="color: Gray;">.</span><span style="color: Blue;">saturate_and_pixelate</span><span style="color: Olive;">(</span><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">mote_gray_pixbuf</span><span style="color: Gray;">, </span><span style="color: Maroon;">0.0</span><span style="color: Gray;">, </span><span style="color: Green;">True</span><span style="color: Olive;">)</span></li></ol></div>
<p><a href='http://guoyong.org/blog/wp-content/uploads/screenshot00.png' title='colored' rel="lightbox[313]"><img src='http://guoyong.org/blog/wp-content/uploads/screenshot00.thumbnail.png' alt='colored' /></a></p>
<p><a href='http://guoyong.org/blog/wp-content/uploads/screenshot01.png' title='grayed' rel="lightbox[313]"><img src='http://guoyong.org/blog/wp-content/uploads/screenshot01.thumbnail.png' alt='grayed' /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/python/pygtk%e9%87%8c%e5%8f%96%e5%be%97%e4%b8%80%e4%b8%aaxpm%e5%9b%be%e6%a0%87%e7%9a%84%e7%81%b0%e5%ba%a6%e5%9b%be/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>glade+pygtk学习 (3)</title>
		<link>http://guoyong.me/python/gladepygtk%e5%ad%a6%e4%b9%a0-3/</link>
		<comments>http://guoyong.me/python/gladepygtk%e5%ad%a6%e4%b9%a0-3/#comments</comments>
		<pubDate>Sat, 28 Oct 2006 12:50:13 +0000</pubDate>
		<dc:creator>wolfg</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://guoyong.org/2006/10/28/280</guid>
		<description><![CDATA[这几天用pygtk和glade写了一个不大的应用，在ubuntu下开发，然后移植到Maemo平台。 学习的过程中发现了SimpleGladeApp.py这个module，可以更方便地以面向对象的方式使用libgrade。 还记得serverinfo这个例子吗？里面是这样得到一个widget的实例的： self.wTree = gtk.glade.XML(self.gladefile, self.windowname)&#160; self.logwindowview = self.wTree.get_widget(&#34;textview1&#34;) 用了SimpleGladeApp.py，直接用self.logwindowview就行了。 下面是改造serverinfo使用SimpleGladeApp.py的步骤： 1. 从 http://www.gnomefiles.org/app.php/SimpleGladeApp.py 下载SimpleGladeApp.py 2. 解压缩后把tepache这个脚本放到你的PATH环境变量指定的路径下，比如/usr/local/bin，然后加上执行权限。 3. 我们已经有现成的serverinfo.glade文件了，现在要做的是用tepache这个脚本解析glade文件来生成一个Python模块，里面是一些对应window或dialog等顶层widget的class，并实现他们的callback方法。命令如下（-o选项是为了不覆盖原来的serverinfo.py）： $ tepache serverinfo.glade -o serverinfo_new.pywritten file serverinfo_new.py$ lsserverinfo.glade&#160; &#160;serverinfo_new.py&#160; &#160; &#160; &#160;serverinfo.pyserverinfo.gladep&#160; serverinfo_new.py.orig&#160; SimpleGladeApp.py 可以看到tepache生成了三个文件：serverinfo_new.py, serverinfo_new.py.orig, SimpleGladeApp.py .orig文件很重要，tepache用这个文件保护你在serverinfo_new.py添加的代码，所以不要删除这个文件。 可以先运行serverinfo_new.py看看效果。 4. &#8230; <a href="http://guoyong.me/python/gladepygtk%e5%ad%a6%e4%b9%a0-3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>这几天用pygtk和glade写了一个不大的应用，在ubuntu下开发，然后移植到Maemo平台。</p>
<p>学习的过程中发现了SimpleGladeApp.py这个module，可以更方便地以面向对象的方式使用libgrade。</p>
<p>还记得serverinfo这个例子吗？里面是这样得到一个widget的实例的：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">wTree</span><span style="color: Gray;"> = </span><span style="color: Blue;">gtk</span><span style="color: Gray;">.</span><span style="color: Blue;">glade</span><span style="color: Gray;">.</span><span style="color: Blue;">XML</span><span style="color: Olive;">(</span><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">gladefile</span><span style="color: Gray;">, </span><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">windowname</span><span style="color: Olive;">)</span><span style="color: Gray;">&nbsp; </span></li>
<li><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">logwindowview</span><span style="color: Gray;"> = </span><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">wTree</span><span style="color: Gray;">.</span><span style="color: Blue;">get_widget</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">textview1</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span></li></ol></div>
<p>用了SimpleGladeApp.py，直接用self.logwindowview就行了。</p>
<p>下面是改造serverinfo使用SimpleGladeApp.py的步骤：</p>
<p>1. 从 http://www.gnomefiles.org/app.php/SimpleGladeApp.py 下载SimpleGladeApp.py</p>
<p>2. 解压缩后把tepache这个脚本放到你的PATH环境变量指定的路径下，比如/usr/local/bin，然后加上执行权限。</p>
<p>3. 我们已经有现成的serverinfo.glade文件了，现在要做的是用tepache这个脚本解析glade文件来生成一个Python模块，里面是一些对应window或dialog等顶层widget的class，并实现他们的callback方法。命令如下（-o选项是为了不覆盖原来的serverinfo.py）：</p>
<div class="hl-surround"><div class="hl-main">$ tepache serverinfo.glade -o serverinfo_new.py<br />written file serverinfo_new.py<br />$ ls<br />serverinfo.glade&nbsp; &nbsp;serverinfo_new.py&nbsp; &nbsp; &nbsp; &nbsp;serverinfo.py<br />serverinfo.gladep&nbsp; serverinfo_new.py.orig&nbsp; SimpleGladeApp.py</div></div>
<p>可以看到tepache生成了三个文件：serverinfo_new.py, serverinfo_new.py.orig, SimpleGladeApp.py<br />
.orig文件很重要，tepache用这个文件保护你在serverinfo_new.py添加的代码，所以不要删除这个文件。</p>
<p>可以先运行serverinfo_new.py看看效果。</p>
<p>4. serverinfo_new.py的部分代码：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Gray;">......</span></li>
<li><span style="color: #ffa500;"># Warning: Do not modify any context comment such as #--</span></li>
<li><span style="color: #ffa500;"># They are required to keep user's code</span></li>
<li><span style="color: Gray;">......</span></li>
<li><span style="color: Green;">from</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">SimpleGladeApp</span><span style="color: Gray;"> </span><span style="color: Green;">import</span><span style="color: Gray;"> </span><span style="color: Blue;">SimpleGladeApp</span></li>
<li><span style="color: Green;">from</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">SimpleGladeApp</span><span style="color: Gray;"> </span><span style="color: Green;">import</span><span style="color: Gray;"> </span><span style="color: Blue;">bindtextdomain</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">app_name</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">serverinfo</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Blue;">app_version</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">0.0.1</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">glade_dir</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;&quot;</span></li>
<li><span style="color: Blue;">locale_dir</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;&quot;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Blue;">bindtextdomain</span><span style="color: Olive;">(</span><span style="color: Blue;">app_name</span><span style="color: Gray;">, </span><span style="color: Blue;">locale_dir</span><span style="color: Olive;">)</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Green;">class</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">Serverinfo</span><span style="color: Olive;">(</span><span style="color: Blue;">SimpleGladeApp</span><span style="color: Olive;">)</span><span style="color: Gray;">:</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Green;">def</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">__init__</span><span style="color: Olive;">(</span><span style="color: Blue;">self</span><span style="color: Gray;">, </span><span style="color: Blue;">path</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">serverinfo.glade</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: Blue;">root</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">serverinfo</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: Blue;">domain</span><span style="color: Gray;">=</span><span style="color: Blue;">app_name</span><span style="color: Gray;">, **</span><span style="color: Blue;">kwargs</span><span style="color: Olive;">)</span><span style="color: Gray;">:</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">path</span><span style="color: Gray;"> = </span><span style="color: Blue;">os</span><span style="color: Gray;">.</span><span style="color: Blue;">path</span><span style="color: Gray;">.</span><span style="color: Blue;">join</span><span style="color: Olive;">(</span><span style="color: Blue;">glade_dir</span><span style="color: Gray;">, </span><span style="color: Blue;">path</span><span style="color: Olive;">)</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">SimpleGladeApp</span><span style="color: Gray;">.</span><span style="color: Blue;">__init__</span><span style="color: Olive;">(</span><span style="color: Blue;">self</span><span style="color: Gray;">, </span><span style="color: Blue;">path</span><span style="color: Gray;">, </span><span style="color: Blue;">root</span><span style="color: Gray;">, </span><span style="color: Blue;">domain</span><span style="color: Gray;">, **</span><span style="color: Blue;">kwargs</span><span style="color: Olive;">)</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: #ffa500;">#-- Serverinfo.new {</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Green;">def</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">new</span><span style="color: Olive;">(</span><span style="color: Blue;">self</span><span style="color: Olive;">)</span><span style="color: Gray;">:</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">print</span><span style="color: Gray;">&nbsp;</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">A new %s has been created</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> % </span><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">__class__</span><span style="color: Gray;">.</span><span style="color: Blue;">__name__</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: #ffa500;">#-- Serverinfo.new }</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: #ffa500;">#-- Serverinfo custom methods {</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: #ffa500;">#&nbsp;&nbsp; Write your own methods here</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: #ffa500;">#-- Serverinfo custom methods }</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: #ffa500;">#-- Serverinfo.on_serverinfo_destroy {</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Green;">def</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">on_serverinfo_destroy</span><span style="color: Olive;">(</span><span style="color: Blue;">self</span><span style="color: Gray;">, </span><span style="color: Blue;">widget</span><span style="color: Gray;">, *</span><span style="color: Blue;">args</span><span style="color: Olive;">)</span><span style="color: Gray;">:</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">print</span><span style="color: Gray;">&nbsp;</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">on_serverinfo_destroy called with self.%s</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> % </span><span style="color: Blue;">widget</span><span style="color: Gray;">.</span><span style="color: Blue;">get_name</span><span style="color: Olive;">()</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: #ffa500;">#-- Serverinfo.on_serverinfo_destroy }</span></li>
<li><span style="color: Gray;">......&nbsp;&nbsp; </span></li>
<li><span style="color: #ffa500;">#-- main {</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Green;">def</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">main</span><span style="color: Olive;">()</span><span style="color: Gray;">:</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Blue;">serverinfo</span><span style="color: Gray;"> = </span><span style="color: Blue;">Serverinfo</span><span style="color: Olive;">()</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Blue;">demodialog</span><span style="color: Gray;"> = </span><span style="color: Blue;">Demodialog</span><span style="color: Olive;">()</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Blue;">serverinfo</span><span style="color: Gray;">.</span><span style="color: Blue;">run</span><span style="color: Olive;">()</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Green;">if</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">__name__</span><span style="color: Gray;"> == </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">__main__</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">:</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Blue;">main</span><span style="color: Olive;">()</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: #ffa500;">#-- main }</span></li></ol></div>
<p>5. 现在就可以添加一些代码来实现serverinfo的功能了。注意不要修改形如#&#8211; Demodialog custom methods { 这样的注释，否则如果界面(glade文件)有了改动，tepache就没法做patch了。</p>
<p>把原来的insert_row改成ServerInfo类的一个方法，放在#&#8211; Serverinfo custom methods 注释之间。<br />
goUrl方法也放在这里。 注意访问widget实例的方法已经由</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">host</span><span style="color: Gray;"> = </span><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">wTree</span><span style="color: Gray;">.</span><span style="color: Blue;">get_widget</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">entry1</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">get_text</span><span style="color: Olive;">()</span></div></div>
<p>变成</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">host</span><span style="color: Gray;"> = </span><span style="color: Blue;">self</span><span style="color: Gray;">.</span><span style="color: Blue;">entry1</span><span style="color: Gray;">.</span><span style="color: Blue;">get_text</span><span style="color: Olive;">()</span></div></div>
<p>main方法里的实例化Demodialog的语句要挪到button2的clicked事件响应方法里，不然程序一运行对话框就出现了，你刚才一定注意到了。</p>
<p>destroy响应方法里加入self.gtk_main_quit()以便窗口销毁时能够退出程序。</p>
<p>6. 现在运行serverinfo_new.py，原来serverinfo.py的功能基本上都有了。但有一个问题，对话框弹出后点击“确定”或“取消”按钮都不能关闭对话框。我的解决办法是不在glade设计这个对话框，完成在程序里用代码实现。</p>
<p>7. 注意每次重新设计了界面，修改了glade文件，都要运行tepache来patch生成的python模块，已做的修改不会被覆盖。</p>
<p>新的代码下载地址： http://guoyong.org/?dl=pygtk-learning-serverinfo-simplegladeapp.tar.bz2</p>
]]></content:encoded>
			<wfw:commentRss>http://guoyong.me/python/gladepygtk%e5%ad%a6%e4%b9%a0-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.705 seconds -->

