<?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>√-1 ♥ PROGRAMMING</title>
	<atom:link href="http://umut.mobi/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://umut.mobi/blog</link>
	<description>by Umut Aydin</description>
	<lastBuildDate>Fri, 06 Aug 2010 13:12:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Jobbar: Open Source Job Server (Single Mode)</title>
		<link>http://umut.mobi/blog/2010/08/06/jobbar-open-source-job-server-single-mode/</link>
		<comments>http://umut.mobi/blog/2010/08/06/jobbar-open-source-job-server-single-mode/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 13:12:10 +0000</pubDate>
		<dc:creator>Umut</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Apache Mina]]></category>
		<category><![CDATA[Java New I/O]]></category>
		<category><![CDATA[Job Server]]></category>

		<guid isPermaLink="false">http://umut.mobi/blog/?p=70</guid>
		<description><![CDATA[Single version of Jobbar is ready to go. Single Server, Socket Handler, Worker Registration, Job Requests &#038; Responses features are available with this version. Worker part is distributed but the job server works single. You can use this single version for authentication, logging, parallel processing, caching, multitasking, etc. All you have to do is to [...]]]></description>
			<content:encoded><![CDATA[<p>Single version of <a href="http://github.com/umaydin/jobbar-single/">Jobbar</a> is ready to go.</p>
<p>Single Server, Socket Handler, Worker Registration, Job Requests &#038; Responses features are available with this version. Worker part is distributed but the job server works single.</p>
<p>You can use this single version for authentication, logging, parallel processing, caching, multitasking, etc. All you have to do is to write workers for each case or you can wait till I get distributed version ready. After that, I&#8217;ll publish some tutorials for different cases.</p>
<p><em>By the way it&#8217;s written in Java and available under MIT license.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://umut.mobi/blog/2010/08/06/jobbar-open-source-job-server-single-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to run Web.py with Apache2 via mod_wsgi</title>
		<link>http://umut.mobi/blog/2010/07/30/how-to-run-web-py-with-apache2-via-mod_wsgi/</link>
		<comments>http://umut.mobi/blog/2010/07/30/how-to-run-web-py-with-apache2-via-mod_wsgi/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 16:02:13 +0000</pubDate>
		<dc:creator>Umut</dc:creator>
				<category><![CDATA[Apache2]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Web.py]]></category>
		<category><![CDATA[mod_wsgi]]></category>

		<guid isPermaLink="false">http://umut.mobi/blog/?p=59</guid>
		<description><![CDATA[Here, I&#8217;m gonna explain how to get your Web.py application works with your Apache web server via mod_wsgi in Ubuntu 10.04. The key is mod_wsgi here. To install mod_wsgi, please run that command first. sudo apt-get install libapache2-mod-wsgi Once you have mod_wsgi installed, you can modify your Apache server configuration to run with your Web.py [...]]]></description>
			<content:encoded><![CDATA[<p>Here, I&#8217;m gonna explain how to get <em>your Web.py application</em> works with your <em>Apache web server</em> via <strong>mod_wsgi</strong> in Ubuntu 10.04. The key is <a href="http://code.google.com/p/modwsgi/" rel="no-follow">mod_wsgi</a> here.</p>
<p>To install mod_wsgi, please run that command first.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">sudo apt-get install libapache2-mod-wsgi</pre></div></div>

<p>Once you have mod_wsgi installed, you can modify your Apache server configuration to run with your Web.py server.</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
    <span style="color: #00007f;">ServerName</span> your-domain
    WSGIScriptAlias / /path-to-your-webpy-file/server.py/
&nbsp;
    <span style="color: #00007f;">AddType</span> text/html .py
&nbsp;
    &lt;<span style="color: #000000; font-weight:bold;">Directory</span> /path-to-your-webpy-file/&gt;
        <span style="color: #00007f;">Order</span> <span style="color: #00007f;">deny</span>,<span style="color: #00007f;">allow</span>
        <span style="color: #00007f;">Allow</span> <span style="color: #00007f;">from</span> <span style="color: #00007f;">all</span>
    &lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></div></div>

<p>Now, we need to make a little bit modification on our code. Please add this line before importing your own (custom) libraries.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #dc143c;">sys</span>.<span style="color: black;">path</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">dirname</span><span style="color: black;">&#40;</span>__file__<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>For more information you can visit <a href="http://webpy.org/cookbook/mod_wsgi-apache" rel="no-follow">official website</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://umut.mobi/blog/2010/07/30/how-to-run-web-py-with-apache2-via-mod_wsgi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Different Approach to Materialized Views on PostgreSQL</title>
		<link>http://umut.mobi/blog/2010/07/19/a-different-approach-to-materialized-views-on-postgresql/</link>
		<comments>http://umut.mobi/blog/2010/07/19/a-different-approach-to-materialized-views-on-postgresql/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 11:50:50 +0000</pubDate>
		<dc:creator>Umut</dc:creator>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Database Server]]></category>
		<category><![CDATA[Gearman]]></category>
		<category><![CDATA[Materialized View]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Worker]]></category>

		<guid isPermaLink="false">http://umut.mobi/blog/?p=48</guid>
		<description><![CDATA[As many of you already know, views are not actual tables. Views are only snapshots of data scopes which pre-defined by you. Because of that, you cannot create any index on a View. But in PostgreSQL, I have informed about a different type of view by my friend: Materialized View. At the very first time, [...]]]></description>
			<content:encoded><![CDATA[<p>As many of you already know, views are not actual tables. Views are only snapshots of data scopes which pre-defined by you. Because of that, you cannot create any index on a View. But in PostgreSQL, I have informed about a different type of view by my friend: <strong>Materialized View</strong>.</p>
<p>At the very first time, it&#8217;s relief to know that there is a structure to store dynamic data and use some indexes on it. But, nothing is what it seems. Lets check what&#8217;s wrong here:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #993333; font-weight: bold;">REPLACE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> refresh_matview<span style="color: #66cc66;">&#40;</span>name<span style="color: #66cc66;">&#41;</span> RETURNS VOID
 SECURITY DEFINER
 <span style="color: #993333; font-weight: bold;">LANGUAGE</span> plpgsql <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">'
 DECLARE 
     matview ALIAS FOR $1;
     entry matviews%ROWTYPE;
 BEGIN
&nbsp;
     SELECT * INTO entry FROM matviews WHERE mv_name = matview;
&nbsp;
     IF NOT FOUND THEN
         RAISE EXCEPTION &lt;nowiki&gt;'</span><span style="color: #ff0000;">'Materialized view % does not exist.'</span><span style="color: #ff0000;">', matview;
    END IF;
&nbsp;
    EXECUTE '</span><span style="color: #ff0000;">'DELETE FROM '</span><span style="color: #ff0000;">' || matview;
    EXECUTE '</span><span style="color: #ff0000;">'INSERT INTO '</span><span style="color: #ff0000;">' || matview
        || '</span><span style="color: #ff0000;">' SELECT * FROM '</span><span style="color: #ff0000;">' || entry.v_name;
&nbsp;
    UPDATE matviews
        SET last_refresh=CURRENT_TIMESTAMP
        WHERE mv_name=matview;
&nbsp;
    RETURN;
END
'</span>;<span style="color: #66cc66;">&lt;/</span>nowiki<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p><em>Materialized Views</em> work on trigger model. If anything happens on your actual tables there are a few functions to call for changing your <em>Materialized Views</em>. Everything is OK at this far. The code block above creates a function on your database server to update your Materialized View. As you can see, on every change this function deletes all data in your <strong>mat_view</strong> and inserts all data from your original view. <strong>This is nothing but deadly cost.</strong></p>
<p><em>So, what can we do instead of using Materialized Views?</em><br />
If you have more experience on PostgreSQL than me maybe you can find a better solution but I&#8217;m not familiar with PostgreSQL as I&#8217;m familier with MySQL. Because of that I handle that kind of works with Gearman Worker as a background job and I put all logic into the worker instead of using any kind of view in PostgreSQL.</p>
]]></content:encoded>
			<wfw:commentRss>http://umut.mobi/blog/2010/07/19/a-different-approach-to-materialized-views-on-postgresql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GittiGidiyor API Client for Symfony Framework</title>
		<link>http://umut.mobi/blog/2010/07/15/gittigidiyor-api-client-for-symfony-framework/</link>
		<comments>http://umut.mobi/blog/2010/07/15/gittigidiyor-api-client-for-symfony-framework/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 16:58:33 +0000</pubDate>
		<dc:creator>Umut</dc:creator>
				<category><![CDATA[PHP5]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Client]]></category>
		<category><![CDATA[GittiGidiyor]]></category>
		<category><![CDATA[Symfony Framework]]></category>

		<guid isPermaLink="false">http://umut.mobi/blog/?p=38</guid>
		<description><![CDATA[GittiGidiyor.com provides an API to make online business. You can find more information at Developer&#8217;s Website. Here, I want to make some modifications on their PHP client to make it suitable with Symfony Framework. I prefer to use version 1.4 but it also works with older versions. Please, add these settings to your app.yml: all: [...]]]></description>
			<content:encoded><![CDATA[<p>GittiGidiyor.com provides an API to make online business. You can find more information at <a href="http://dev.gittigidiyor.com/araclar-dokumanlar" rel="no-follow">Developer&#8217;s Website</a>.</p>
<p>Here, I want to make some modifications on their PHP client to make it suitable with <strong>Symfony Framework</strong>. I prefer to use version 1.4 but it also works with older versions.</p>
<p>Please, add these settings to your <em>app.yml</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">all:
    gittigidiyor:
        apiKey: APPLICATION-KEY
        secretKey: SECRET-KEY
        nick: NICK
        password: PASSWORD
        authUser: AUTHENTICATION-USERNAME
        authPass: AUTHENTICATION-PASSWORD
        lang: LANGUAGE</pre></div></div>

<p>Now, we can reach them via <em>sfConfig::get().</em> This way is better than INI file while you&#8217;re working with Symfony Framework.</p>
<p>You can download the code at <a href="http://github.com/umaydin/sfGGClient/blob/master/sfGGClient.class.php">Github</a>. By the way, I have modified only <em>__construct</em> method. If you want to make this modification yourself please replace the original <em>__construct</em> with the code below:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">apiKey</span> <span style="color: #339933;">=</span> sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'app_gittigidiyor_apiKey'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">secretKey</span> <span style="color: #339933;">=</span> sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'app_gittigidiyor_secretKey'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nick</span> <span style="color: #339933;">=</span> sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'app_gittigidiyor_nick'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">password</span> <span style="color: #339933;">=</span> sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'app_gittigidiyor_password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">auth_user</span> <span style="color: #339933;">=</span> sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'app_gittigidiyor_authUser'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">auth_pass</span> <span style="color: #339933;">=</span> sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'app_gittigidiyor_authPass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lang</span> <span style="color: #339933;">=</span> sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'app_gittigidiyor_lang'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$usec</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sec</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">time</span> <span style="color: #339933;">=</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>float<span style="color: #009900;">&#41;</span><span style="color: #000088;">$usec</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>float<span style="color: #009900;">&#41;</span><span style="color: #000088;">$sec</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'0'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sign</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">apiKey</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">secretKey</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://umut.mobi/blog/2010/07/15/gittigidiyor-api-client-for-symfony-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web.py Tutorial</title>
		<link>http://umut.mobi/blog/2010/07/02/web-py-tutorial/</link>
		<comments>http://umut.mobi/blog/2010/07/02/web-py-tutorial/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 10:02:04 +0000</pubDate>
		<dc:creator>Umut</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Web.py]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Web Server]]></category>

		<guid isPermaLink="false">http://umut.mobi/blog/?p=16</guid>
		<description><![CDATA[In Ubuntu 10.04, I started with running that command in shell: $ sudo apt-get install python-webpy After that, I was ready for importing web library. #!/usr/bin/env python # -*- coding: utf-8 -*- &#160; import web import web.utils Then, I modified url handling rules for my application. Url handling is based on classes. We need to [...]]]></description>
			<content:encoded><![CDATA[<p>In <em>Ubuntu 10.04</em>, I started with running that command in shell:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">$ sudo apt-get install python-webpy</pre></div></div>

<p>After that, I was ready for importing web library.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #808080; font-style: italic;"># -*- coding: utf-8 -*-</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> web
<span style="color: #ff7700;font-weight:bold;">import</span> web.<span style="color: black;">utils</span></pre></div></div>

<p>Then, I modified url handling rules for my application. Url handling is based on classes. We need to specify class name for each url.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">urls = <span style="color: black;">&#40;</span>
    <span style="color: #483d8b;">'/(.*)'</span>, <span style="color: #483d8b;">'MyClass'</span>
<span style="color: black;">&#41;</span></pre></div></div>

<p>Most important thing is that these classes must have method(s) called POST and/or GET. Because these methods will be called automatically by Web.py</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> MyClass:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">pass</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> POST<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, query<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">pass</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> GET<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, query<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">pass</span></pre></div></div>

<p>Basically, that&#8217;s how we implement Web.py but I want to share more useful things.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        web.<span style="color: black;">config</span>.<span style="color: black;">debug</span> = <span style="color: #008000;">False</span>
&nbsp;
        <span style="color: #008000;">self</span>.<span style="color: black;">cache</span> = memcache.<span style="color: black;">Client</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'%s:%s'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>host, port<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">db</span>     = web.<span style="color: black;">database</span><span style="color: black;">&#40;</span>dbn=<span style="color: #483d8b;">'postgres'</span>, 
                                   driver=<span style="color: #483d8b;">'psycopg2'</span>, 
                                   db=<span style="color: #483d8b;">'%s'</span>, <span style="color: #dc143c;">user</span>=<span style="color: #483d8b;">'%s'</span>, 
                                   host=<span style="color: #483d8b;">'localhost'</span>, 
                                   password=<span style="color: #483d8b;">'%s'</span> <span style="color: #66cc66;">%</span> 
                                   <span style="color: black;">&#40;</span>dbname, dbuser, dbpass<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>You need to install <em>python-memcache</em> library before importing <em>memcache</em> to your application.</p>
<p>If you want to handle parameters, that&#8217;s easy too. <strong>web.input()</strong> returns you an object for parameters.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">params = web.<span style="color: #008000;">input</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> params.<span style="color: black;">name</span>
<span style="color: #ff7700;font-weight:bold;">print</span> params.<span style="color: black;">surname</span></pre></div></div>

<p><strong>Handling Query Strings:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urlparse</span>
&nbsp;
params = <span style="color: #dc143c;">urlparse</span>.<span style="color: black;">parse_qs</span><span style="color: black;">&#40;</span>web.<span style="color: black;">ctx</span>.<span style="color: black;">query</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> params.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'param_name'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span></pre></div></div>

<p><strong>Some Examples:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #008000;">self</span>.<span style="color: black;">cache</span>.<span style="color: #008000;">set</span><span style="color: black;">&#40;</span>key, val<span style="color: black;">&#41;</span>
val = <span style="color: #008000;">self</span>.<span style="color: black;">cache</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span>key<span style="color: black;">&#41;</span>
&nbsp;
resultset = <span style="color: #008000;">self</span>.<span style="color: black;">db</span>.<span style="color: black;">query</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;SELECT id FROM test_table 
                                      WHERE username='%s';&quot;</span> 
                                        <span style="color: #66cc66;">%</span> name<span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>resultset<span style="color: black;">&#41;</span>:
    <span style="color: #008000;">id</span> = resultset<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: #008000;">id</span></pre></div></div>

<p>For more information please check <a rel="no-follow" target="_blank" href="http://webpy.org">official website</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://umut.mobi/blog/2010/07/02/web-py-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
