<?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>The world (and word) of jaymz &#187; django</title>
	<atom:link href="http://jaymz.eu/tag/django/feed/" rel="self" type="application/rss+xml" />
	<link>http://jaymz.eu</link>
	<description></description>
	<lastBuildDate>Tue, 17 Jan 2012 21:42:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Automatic superusers via Active Collab for django</title>
		<link>http://jaymz.eu/2011/02/automatic-superusers-via-active-collab-for-django/</link>
		<comments>http://jaymz.eu/2011/02/automatic-superusers-via-active-collab-for-django/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 21:20:42 +0000</pubDate>
		<dc:creator>jaymz</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[active-collab]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://jaymz.eu/?p=553</guid>
		<description><![CDATA[Two things I use a lot at work &#8211; Django and Active Collab. One is the python framework we build everything on and the other is a project management tool that we use &#8211; think a local install of Basecamp roughly. It can get annoying when we create development versions of things we&#8217;re working on [...]]]></description>
			<content:encoded><![CDATA[<p>Two things I use a lot at work &#8211; <a href="http://www.djangoproject.com/">Django</a> and <a href="http://www.activecollab.com">Active Collab</a>. One is the python framework we build everything on and the other is a project management tool that we use &#8211; think a local install of Basecamp roughly.</p>
<p>It can get annoying when we create development versions of things we&#8217;re working on and have to go and create test users for people; so I thought since writing an auth backend for django is so easy why not just use that to allow any user with a valid Active Collab account to login to the dev admin.</p>
<p><a href="http://jaymz.eu/wp-content/uploads/2011/02/ac-authbackend.jpg"><img class="aligncenter size-full wp-image-560" title="ac-authbackend" src="http://jaymz.eu/wp-content/uploads/2011/02/ac-authbackend.jpg" alt="" width="525" height="295" /></a></p>
<p>The <a href="https://github.com/jaymzcd/django-acollabauth">code is on github</a> and will automatically create a superuser in django&#8217;s auth table. Users can then login with their active collab emails &amp; passwords without having to pass around test accounts. It also means users wont suddenly lose access when you nuke the database for imports saving you some earache. Just add your base active collab url to the <em>AC_URL</em> variable in settings.py and add &#8216;<em>acollabauth.backends.ActiveCollabBackend</em>&#8216; to your AUTHENTICATION_BACKENDS tuple.</p>
<p>I have also blogged about this <a href="http://www.u-dox.com/blog/2011/02/22/using-active-collab-to-authenticate-django-sites/">over at udox</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaymz.eu/2011/02/automatic-superusers-via-active-collab-for-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirecting users in django based on client IP</title>
		<link>http://jaymz.eu/2011/02/redirecting-users-in-django-based-on-client-ip/</link>
		<comments>http://jaymz.eu/2011/02/redirecting-users-in-django-based-on-client-ip/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 10:34:55 +0000</pubDate>
		<dc:creator>jaymz</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[geocoding]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://jaymz.eu/?p=541</guid>
		<description><![CDATA[geoip-redirect is available on my github page.]]></description>
			<content:encoded><![CDATA[<p><a href="http://jaymz.eu/wp-content/uploads/2011/02/redirect-vans.jpg"><img class="aligncenter size-full wp-image-542" title="redirect-vans" src="http://jaymz.eu/wp-content/uploads/2011/02/redirect-vans.jpg" alt="" width="525" height="295" /></a><a href="https://github.com/jaymzcd/geoip-redirect"></a></p>
<p><a href="https://github.com/jaymzcd/geoip-redirect">geoip-redirect</a> is available on my github page.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaymz.eu/2011/02/redirecting-users-in-django-based-on-client-ip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrating ooyala in django (or just python)</title>
		<link>http://jaymz.eu/2010/07/integrating-ooyala-in-django-or-just-python/</link>
		<comments>http://jaymz.eu/2010/07/integrating-ooyala-in-django-or-just-python/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 11:34:26 +0000</pubDate>
		<dc:creator>jaymz</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[ooyala]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://jaymz.eu/?p=495</guid>
		<description><![CDATA[Ooyala is a feature rich video hosting platform. Something I needed recently was some way to link the data over at ooyala into a django site I&#8217;m building. So I wrote myself a library. It&#8217;s available over at github and it&#8217;s called (predictably) django-ooyala. Currently there is a management command syncooyala to pull in all [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jaymz.eu/wp-content/uploads/2010/07/django-ooyala-logo.png"><img class="aligncenter size-full wp-image-497" title="django-ooyala-logo" src="http://jaymz.eu/wp-content/uploads/2010/07/django-ooyala-logo.png" alt="" width="350" height="133" /></a></p>
<p>Ooyala is a feature rich video hosting platform. Something I needed recently was some way to link the data over at ooyala into a django site I&#8217;m building. So I wrote myself a library. It&#8217;s available over at github and it&#8217;s called (predictably) <em><a href="http://github.com/jaymzcd/django-ooyala">django-ooyala</a>.</em> Currently there is a management command <strong>syncooyala</strong> to pull in all the data using the Backlot Query API. These imported items are then linked to a specific URL. Finally in your templates there is a <em>ooyala_video</em> tag which when given the current path (via request.path) returns the &lt;script&gt; tags needed for it to render.</p>
<p>Expect some updates as I flesh it out into the front end over the next few days.</p>
<p><strong><em>Updated (11th August): <span style="font-weight: normal;">I have added in analytics support. You can now make requests for video stat&#8217;s for a given account or video. The facebook SDK has also been added with a new template tag to output the headers in your template for a given video. Remember to request whitelisting from facebook for SWF embeds to work.</span></em></strong></p>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaymz.eu/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="python"><span class="kw1">from</span> django.<span class="me1">http</span> <span class="kw1">import</span> HttpResponse
<span class="kw1">from</span> ooyala.<span class="me1">library</span> <span class="kw1">import</span> OoyalaAnalytics
<span class="kw1">from</span> ooyala.<span class="me1">constants</span> <span class="kw1">import</span> OoyalaConstants as O
<span class="kw1">from</span> ooyala.<span class="me1">models</span> <span class="kw1">import</span> OoyalaItem
&nbsp;
<span class="kw1">def</span> backlot_query<span class="br0">&#40;</span>request<span class="br0">&#41;</span>:
    req = OoyalaAnalytics<span class="br0">&#40;</span>video=OoyalaItem.<span class="me1">objects</span>.<span class="me1">all</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>.<span class="me1">embed_code</span>, \
        method=O.<span class="me1">ANALYTIC_METHODS</span>.<span class="me1">VIDEO</span><span class="br0">&#41;</span>
    ooyala_response = req.<span class="me1">process</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
    <span class="kw1">return</span> HttpResponse<span class="br0">&#40;</span>ooyala_response.<span class="me1">toprettyxml</span><span class="br0">&#40;</span><span class="br0">&#41;</span>, mimetype=<span class="st0">&quot;text/xml&quot;</span><span class="br0">&#41;</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://jaymz.eu/2010/07/integrating-ooyala-in-django-or-just-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SpineMagazine.com radio player &amp; news reader for android</title>
		<link>http://jaymz.eu/2010/07/spinemagazine-com-radio-player-news-reader-for-android/</link>
		<comments>http://jaymz.eu/2010/07/spinemagazine-com-radio-player-news-reader-for-android/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 00:20:38 +0000</pubDate>
		<dc:creator>jaymz</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://jaymz.eu/?p=467</guid>
		<description><![CDATA[Quite a while back I was trying to get my head around the fairly complex ListView control for android and something I thought perfect for it was the set of radio shows over at spine magazine. I have had this code sitting around for a while and I thought why not knock out the news [...]]]></description>
			<content:encoded><![CDATA[<p>Quite a while back I was trying to get my head around the fairly complex <a href="http://developer.android.com/reference/android/widget/ListView.html">ListView</a> control for android and something I thought perfect for it was the set of radio shows over at <a href="http://www.spinemagazine.com">spine magazine</a>.</p>
<table width="100%">
<tbody>
<tr>
<td>
<p style="text-align: center;"><a href="http://jaymz.eu/wp-content/uploads/2010/07/screen-shows.png"><img class="aligncenter size-full wp-image-469" title="screen-shows" src="http://jaymz.eu/wp-content/uploads/2010/07/screen-shows.png" alt="" width="224" height="336" /></a></p>
</td>
<td>
<p style="text-align: center;"><a href="http://jaymz.eu/wp-content/uploads/2010/07/screen-news1.png"><img class="aligncenter size-full wp-image-476" title="screen-news" src="http://jaymz.eu/wp-content/uploads/2010/07/screen-news1.png" alt="" width="224" height="336" /></a></p>
</td>
</tr>
</tbody>
</table>
<p>I have had this code sitting around for a while and I thought why not knock out the news code and release it and then just continue to work on it and update it. As the saying goes, <em>release early, release often!</em> I think it&#8217;ll be easy enough to add in reviews using the same sort of code to get the data and just re-using the show layout. This particular app was a lot more complicated than the django-reference thing, so here is some of what I&#8217;ve learned&#8230; You can get this in the marketplace now. Bug reports are expected &amp; indeed welcome.</p>
<p><a href="http://jaymz.eu/wp-content/uploads/2010/07/logo.png"><img class="aligncenter size-full wp-image-484" title="logo" src="http://jaymz.eu/wp-content/uploads/2010/07/logo.png" alt="" width="100" height="100" /></a></p>
<p><span style="color: #ff0000;"><strong>Warning! Technical crap follows.</strong></span></p>
<p>It takes a bit of time to get your head around it, essentially you subclass the <a href="http://developer.android.com/reference/android/widget/ArrayAdapter.html">ArrayAdapter</a> class with a container class to hold your list view elements. The ArrayAdapter is a templated class so you first need another class that is actually going to hold your data. This is were you&#8217;ll need to create a class for your data and then instantiate the ArrayList with this type. The code to hold my news post data is very simple:</p>
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaymz.eu/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="java"><span class="kw2">package</span> eu.<span class="me1">jaymz</span>.<span class="me1">spinemag</span>;
&nbsp;
<span class="co2">import android.util.Log;</span>
&nbsp;
<span class="kw2">public</span> <span class="kw2">class</span> NewsPost <span class="br0">&#123;</span>
    <span class="kw2">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> title;
    <span class="kw2">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> description;
    <span class="kw2">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> date;
    <span class="kw2">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> author;
&nbsp;
    <span class="kw2">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> getTitle<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">return</span> title;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <span class="kw4">void</span> setTitle<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> title<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">this</span>.<span class="me1">title</span> = title;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> getDescription<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">return</span> description;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <span class="kw4">void</span> setDescription<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> description<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">this</span>.<span class="me1">description</span> = description;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> getAuthor<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">return</span> author;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <span class="kw4">void</span> setAuthor<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> author<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">this</span>.<span class="me1">author</span> = author;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> getDate<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">return</span> date;
    <span class="br0">&#125;</span>
    <span class="kw2">public</span> <span class="kw4">void</span> setDate<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> date<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">this</span>.<span class="me1">date</span> = date;
    <span class="br0">&#125;</span>
&nbsp;
<span class="br0">&#125;</span></pre></div></div>
<p>Then in my main activity class I cast the templated ArrayList to a NewsPost class:</p>
<p><strong><strong>ArrayList&lt;NewsPost&gt; spr_news = new ArrayList&lt;NewsPost&gt;();</strong></strong></p>
<p>With the data structure sorted I need a method in my ListView activity to actually fill in the ArrayList with data. This is very typically something along the lines of the following, here I read the JSON data from a URL, decode it and assign it to the class members, finally appending it to the ArrayList from earlier.</p>
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaymz.eu/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="java"><span class="kw2">private</span> <span class="kw4">void</span> getPosts<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw2">try</span> <span class="br0">&#123;</span>
            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AURL+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">URL</span></a> url = <span class="kw2">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AURL+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">URL</span></a><span class="br0">&#40;</span><span class="st0">&quot;url for data&quot;</span><span class="br0">&#41;</span>;
            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ABufferedReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">BufferedReader</span></a> in = <span class="kw2">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ABufferedReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">BufferedReader</span></a><span class="br0">&#40;</span><span class="kw2">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AInputStreamReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">InputStreamReader</span></a><span class="br0">&#40;</span>url.<span class="me1">openStream</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
            <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> str = in.<span class="me1">readLine</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
            in.<span class="me1">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
            spr_news = <span class="kw2">new</span> ArrayList&lt;NewsPost&gt;<span class="br0">&#40;</span><span class="br0">&#41;</span>;
            JSONObject json = <span class="kw2">new</span> JSONObject<span class="br0">&#40;</span>str<span class="br0">&#41;</span>;
            JSONArray posts = json.<span class="me1">getJSONArray</span><span class="br0">&#40;</span><span class="st0">&quot;posts&quot;</span><span class="br0">&#41;</span>;
            <span class="kw1">for</span><span class="br0">&#40;</span><span class="kw4">int</span> x=<span class="nu0">0</span>; x &lt; posts.<span class="me1">length</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; x++<span class="br0">&#41;</span> <span class="br0">&#123;</span>
                JSONObject post_data = <span class="kw2">new</span> JSONObject<span class="br0">&#40;</span>posts.<span class="me1">get</span><span class="br0">&#40;</span>x<span class="br0">&#41;</span>.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                NewsPost post = <span class="kw2">new</span> NewsPost<span class="br0">&#40;</span><span class="br0">&#41;</span>;
                post.<span class="me1">setTitle</span><span class="br0">&#40;</span>post_data.<span class="me1">get</span><span class="br0">&#40;</span><span class="st0">&quot;title&quot;</span><span class="br0">&#41;</span>.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                post.<span class="me1">setDescription</span><span class="br0">&#40;</span>post_data.<span class="me1">get</span><span class="br0">&#40;</span><span class="st0">&quot;description&quot;</span><span class="br0">&#41;</span>.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                post.<span class="me1">setDate</span><span class="br0">&#40;</span>post_data.<span class="me1">get</span><span class="br0">&#40;</span><span class="st0">&quot;date&quot;</span><span class="br0">&#41;</span>.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                post.<span class="me1">setAuthor</span><span class="br0">&#40;</span>post_data.<span class="me1">get</span><span class="br0">&#40;</span><span class="st0">&quot;author&quot;</span><span class="br0">&#41;</span>.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                spr_news.<span class="me1">add</span><span class="br0">&#40;</span>post<span class="br0">&#41;</span>;
                <span class="co1">//Log.d(&quot;NEW&quot;, &quot;added a post - &quot;+post.getTitle());</span>
            <span class="br0">&#125;</span>
        <span class="br0">&#125;</span> <span class="kw2">catch</span> <span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Exception</span></a> e<span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp;
        <span class="br0">&#125;</span>
        runOnUiThread<span class="br0">&#40;</span>setPosts<span class="br0">&#41;</span>;
    <span class="br0">&#125;</span></pre></div></div><br />
</strong></strong></p>
<p>With all the above in place the code is at the point where there is now an array full of structured data for our ArrayAdapter to show. To do this the ArrayAdapter needs subclassed to work with our earlier NewsPost classes members:</p>
<p><div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaymz.eu/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="java"><span class="kw2">private</span> <span class="kw2">class</span> NewsAdapter <span class="kw2">extends</span> ArrayAdapter&lt;NewsPost&gt; <span class="br0">&#123;</span>
&nbsp;
        <span class="kw2">private</span> ArrayList&lt;NewsPost&gt; items;
&nbsp;
        <span class="kw2">public</span> NewsAdapter<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AContext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Context</span></a> context, <span class="kw4">int</span> textViewResourceId, ArrayList&lt;NewsPost&gt; items<span class="br0">&#41;</span> <span class="br0">&#123;</span>
                <span class="kw2">super</span><span class="br0">&#40;</span>context, textViewResourceId, items<span class="br0">&#41;</span>;
                <span class="kw2">this</span>.<span class="me1">items</span> = items;
        <span class="br0">&#125;</span>
        @Override
        <span class="kw2">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">View</span></a> getView<span class="br0">&#40;</span><span class="kw4">int</span> position, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">View</span></a> convertView, ViewGroup parent<span class="br0">&#41;</span> <span class="br0">&#123;</span>
                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">View</span></a> v = convertView;
                <span class="kw1">if</span> <span class="br0">&#40;</span>v == <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                    LayoutInflater vi = <span class="br0">&#40;</span>LayoutInflater<span class="br0">&#41;</span>getSystemService<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AContext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Context</span></a>.<span class="me1">LAYOUT_INFLATER_SERVICE</span><span class="br0">&#41;</span>;
                    v = vi.<span class="me1">inflate</span><span class="br0">&#40;</span>R.<span class="me1">layout</span>.<span class="me1">post</span>, <span class="kw2">null</span><span class="br0">&#41;</span>;
                <span class="br0">&#125;</span>
                NewsPost o = items.<span class="me1">get</span><span class="br0">&#40;</span>position<span class="br0">&#41;</span>;
                <span class="kw1">if</span> <span class="br0">&#40;</span>o != <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                    <span class="coMULTI">/* hmm, this looks proper ugly */</span>
                    TextView title = <span class="br0">&#40;</span>TextView<span class="br0">&#41;</span>v.<span class="me1">findViewById</span><span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">post_title</span><span class="br0">&#41;</span>;
                    TextView description = <span class="br0">&#40;</span>TextView<span class="br0">&#41;</span>v.<span class="me1">findViewById</span><span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">post_description</span><span class="br0">&#41;</span>;
                    TextView date = <span class="br0">&#40;</span>TextView<span class="br0">&#41;</span>v.<span class="me1">findViewById</span><span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">post_date</span><span class="br0">&#41;</span>;
                    TextView author = <span class="br0">&#40;</span>TextView<span class="br0">&#41;</span>v.<span class="me1">findViewById</span><span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">post_author</span><span class="br0">&#41;</span>;
&nbsp;
                    description.<span class="me1">setText</span><span class="br0">&#40;</span>o.<span class="me1">getDescription</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                    title.<span class="me1">setText</span><span class="br0">&#40;</span>o.<span class="me1">getTitle</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                    author.<span class="me1">setText</span><span class="br0">&#40;</span>o.<span class="me1">getAuthor</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                    date.<span class="me1">setText</span><span class="br0">&#40;</span>o.<span class="me1">getDate</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
                <span class="br0">&#125;</span>
                <span class="kw2">return</span> v;
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span></pre></div></div>
<p>All this code is really doing is loading the layout resource XML for our row and binding the data from the array elements members to views within the XML. Finally we need to tell the list view to update. Typically the above code has all been kicked off and ran in a thread, populating the ListView when it&#8217;s actually finished without stalling the phone itself.</p>
<div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaymz.eu/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="java"><span class="kw1">for</span><span class="br0">&#40;</span><span class="kw4">int</span> i=<span class="nu0">0</span>;i&lt;spr_news.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;i++<span class="br0">&#41;</span> <span class="br0">&#123;</span>
    n_adapter.<span class="me1">add</span><span class="br0">&#40;</span>spr_news.<span class="me1">get</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span><span class="br0">&#41;</span>;
<span class="br0">&#125;</span>
m_ProgressDialog.<span class="me1">dismiss</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
n_adapter.<span class="me1">notifyDataSetChanged</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</pre></div></div>
<p>All the above is doing is updating the ArrayAdapter and adding our ArrayList elements to display. We then signal that the data has changed which will cause the ListView itself to update. Simple! <img src='http://jaymz.eu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Again, I must make the point of how verbose this all feels when I&#8217;m coding in python all day. I&#8217;m sure it needs a good refactor to now but I&#8217;m a lot more familiar with the way android works with layouts and indeed <strong>strong</strong> typing <img src='http://jaymz.eu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://jaymz.eu/2010/07/spinemagazine-com-radio-player-news-reader-for-android/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Blogger to Django integration</title>
		<link>http://jaymz.eu/2010/06/google-blogger-to-django-integration/</link>
		<comments>http://jaymz.eu/2010/06/google-blogger-to-django-integration/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 21:45:57 +0000</pubDate>
		<dc:creator>jaymz</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[blogger]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://jaymz.eu/?p=447</guid>
		<description><![CDATA[I&#8217;ve been working a lot on Vans recently and they have a large number of blogs that are currently hosted on the blogger platform. This works really well for them, they have a straightforward &#38; easy to use blog platform that does what they need it to do.  The sites themselves work great as they [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working a lot on <a href="http://www.vans.com">Vans</a> recently and they have a large number of blogs that are currently hosted on the blogger platform. This works really well for them, they have a straightforward &amp; easy to use blog platform that does what they need it to do.  The sites themselves work great as they are but the integration into the main site isn&#8217;t quite as nice.</p>
<p>If you go to the <a href="http://www.vans.com/vans/teamblog.asp">blogs section</a> on vans as it stands it will pull in an XML feed of all the current blogs and display them on one giagantic page. It can take a fair bit of time to load and its hard to see how each different blog gets displayed as its really one big list. For now it&#8217;s not so easy to pull in bits of content from the various blogs without someone having to mess with files or copy &amp; paste, with the build in django I wanted to create a much cleaner &amp; easier way to work with this content.</p>
<p><a href="http://github.com/jaymzcd/django-blogger"><img class="aligncenter size-full wp-image-460" title="blogger-django-logo" src="http://jaymz.eu/wp-content/uploads/2010/06/blogger-django-logo.png" alt="" width="100" height="99" /></a></p>
<p>For this I introduce <a href="http://github.com/jaymzcd/django-blogger">django-blogger</a>, a django application which will integrate Google Blogger blogs via their RSS feeds. As it is it will import the blogs for a given profile id and then sync up with the latest data via their RSS feeds. These can be <a href="http://www.google.com/support/blogger/bin/answer.py?hl=en&amp;answer=97933">enabled easily</a> for your given blogs. When you first install it comes with some admin actions which will all ow you to sync up the blogs manually all at once. There is also a management command, <em>syncblogs,</em> which is more suited to scheduling an update via cron (if you&#8217;re going to use cron you might be interested in <a href="http://code.google.com/p/django-crontab/">django-crontab</a>).</p>
<p><a href="http://jaymz.eu/wp-content/uploads/2010/06/djangoblogs-syncing-command.png"><img class="aligncenter size-full wp-image-451" title="djangoblogs-syncing-command" src="http://jaymz.eu/wp-content/uploads/2010/06/djangoblogs-syncing-command.png" alt="" width="514" height="252" /></a></p>
<p>This works on the feeds and not an archive, so it doesn&#8217;t require authentication, just access to the feed URL. A basic template is included to show how to render out the blog posts &amp; blogs as a menu, I override these myself for the format I need. The app itself now lets me pull content from any of the blogs and use it within the rest of the django based site cleanly &amp; easily. Rather than directly reading and displaying via the feed URL I&#8217;m creating actual objects for each post and blog so it&#8217;s easily extendible also, say to return posts in various formats or pulling images from each blog post to create blog galleries automatically.</p>
<p><img src="http://jaymz.eu/wp-content/uploads/2010/06/blogs-4.png" alt="" /></p>
<p>The code is available from <a href="http://github.com/jaymzcd/django-blogger">GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaymz.eu/2010/06/google-blogger-to-django-integration/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Django Reference in android market now</title>
		<link>http://jaymz.eu/2010/05/django-reference-in-android-market-now/</link>
		<comments>http://jaymz.eu/2010/05/django-reference-in-android-market-now/#comments</comments>
		<pubDate>Fri, 28 May 2010 13:36:20 +0000</pubDate>
		<dc:creator>jaymz</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://jaymz.eu/2010/05/django-reference-in-android-market-now/</guid>
		<description><![CDATA[Very late last night, as I was enjoying &#8220;The Design &#38; Evolution of C++&#8221; (an excellent book, even if you&#8217;re not a C++ dev), I took a short break and was browsing around on the android market place and noticed there was no django app. I&#8217;ve recently picked up an HTC desire and have been [...]]]></description>
			<content:encoded><![CDATA[<p>Very late last night, as I was enjoying &#8220;<a href="http://www.amazon.co.uk/Design-Evolution-C-Bjarne-Stroustrup/dp/0201543303/ref=sr_1_2?ie=UTF8&amp;s=books&amp;qid=1275053838&amp;sr=8-2">The Design &amp; Evolution of C++</a>&#8221; (an excellent book, even if you&#8217;re not a C++ dev), I took a short break and was browsing around on the android market place and noticed there was no django app. I&#8217;ve recently picked up an HTC desire and have been really enjoying developing on it. I&#8217;m currently working on an application for Crooked Tongues to allow people to post &amp; comment their sneakers (don&#8217;t ask&#8230;) and I thought this would be a quick app to do and get out there. Anyone starting out developing apps will be aware that one of the hardest things is just thinking of something that isn&#8217;t already crowded out by what&#8217;s already available.</p>
<p>Basically, all I wanted was a more dedicated browser for the django docs. The content there is excellent so I quickly knocked together an application that lets you jump to major sections, set a page zoom by default and switch version easily. All in all it only took a few hours of development and thanks to the approval procedure it&#8217;s already available to install.</p>
<p><a href="http://jaymz.eu/wp-content/uploads/2010/05/icon.png"><img class="aligncenter size-full wp-image-373" title="icon" src="http://jaymz.eu/wp-content/uploads/2010/05/icon.png" alt="" width="180" height="180" /></a></p>
<p>It&#8217;s a glorified web view but it&#8217;s a start point and its at least out there now. I&#8217;m getting a lot more used to the dev process now on android. The total code for this app weighs in around 400 lines &#8211; around 80 of those being XML to define the layout and strings used. The main activity class then manipulates the XML defined webview component to react to the (again XML) menu. My main constructor method looks like this:</p>
<div id="wpshdo_6" class="wp-synhighlighter-outer"><div id="wpshdt_6" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_6"></a><a id="wpshat_6" class="wp-synhighlighter-title" href="#codesyntax_6"  onClick="javascript:wpsh_toggleBlock(6)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_6" onClick="javascript:wpsh_code(6)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_print(6)" title="Print code"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaymz.eu/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaymz.eu/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_6" class="wp-synhighlighter-inner" style="display: block;"><pre class="java">@Override
    <span class="kw2">public</span> <span class="kw4">void</span> onCreate<span class="br0">&#40;</span>Bundle savedInstanceState<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        Resources res = getResources<span class="br0">&#40;</span><span class="br0">&#41;</span>;
&nbsp;
        version = res.<span class="me1">getString</span><span class="br0">&#40;</span>R.<span class="me1">string</span>.<span class="me1">default_version</span><span class="br0">&#41;</span>;
        base_url = res.<span class="me1">getString</span><span class="br0">&#40;</span>R.<span class="me1">string</span>.<span class="me1">url_base</span><span class="br0">&#41;</span>;
&nbsp;
        <span class="kw2">super</span>.<span class="me1">onCreate</span><span class="br0">&#40;</span>savedInstanceState<span class="br0">&#41;</span>;
        setContentView<span class="br0">&#40;</span>R.<span class="me1">layout</span>.<span class="me1">main</span><span class="br0">&#41;</span>;
        webview = <span class="br0">&#40;</span>WebView<span class="br0">&#41;</span> findViewById<span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">webview</span><span class="br0">&#41;</span>;
&nbsp;
        webview.<span class="me1">getSettings</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">setJavaScriptEnabled</span><span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span>;
        webview.<span class="me1">setWebViewClient</span><span class="br0">&#40;</span><span class="kw2">new</span> DjangoWebClient<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
&nbsp;
        <span class="kw2">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">View</span></a> zc = webview.<span class="me1">getZoomControls</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
        FrameLayout mContentView = <span class="br0">&#40;</span>FrameLayout<span class="br0">&#41;</span> getWindow<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">getDecorView</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">findViewById</span><span class="br0">&#40;</span>android.<span class="me1">R</span>.<span class="me1">id</span>.<span class="me1">content</span><span class="br0">&#41;</span>;
        mContentView.<span class="me1">addView</span><span class="br0">&#40;</span>zc, ZOOM_PARAMS<span class="br0">&#41;</span>;
        zc.<span class="me1">setVisibility</span><span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AView+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">View</span></a>.<span class="me1">GONE</span><span class="br0">&#41;</span>;
&nbsp;
        setZoom<span class="br0">&#40;</span><span class="br0">&#41;</span>;
        loadDocs<span class="br0">&#40;</span><span class="br0">&#41;</span>;
    <span class="br0">&#125;</span></pre></div></div>
<p>The remainder of the methods are basically just reacting to the menu choices and directing the webview url appropriately. All in all quite simple.</p>
<p style="text-align: center;"><a href="http://jaymz.eu/wp-content/uploads/2010/05/release.png"><img class="aligncenter size-full wp-image-377" title="release" src="http://jaymz.eu/wp-content/uploads/2010/05/release.png" alt="" width="560" height="336" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://jaymz.eu/2010/05/django-reference-in-android-market-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crooked Tongues TIA android app &#8211; Week 1</title>
		<link>http://jaymz.eu/2010/05/crooked-tongues-tia-android-app-week-1/</link>
		<comments>http://jaymz.eu/2010/05/crooked-tongues-tia-android-app-week-1/#comments</comments>
		<pubDate>Sun, 16 May 2010 23:22:14 +0000</pubDate>
		<dc:creator>jaymz</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://jaymz.eu/?p=346</guid>
		<description><![CDATA[I recently picked up an HTC desire and have been loving android as a platform. I&#8217;m not entirely sure why I didn&#8217;t go for android to begin with (apart from doing my friend Spangsberg a favour by buying out his iPhone contract before he left the country). I dabbled a little with objective C but [...]]]></description>
			<content:encoded><![CDATA[<p>I recently picked up an HTC desire and have been loving android as a platform. I&#8217;m not entirely sure why I didn&#8217;t go for android to begin with (apart from doing my friend Spangsberg a favour by buying out his iPhone contract before he left the country). I dabbled a little with objective C but not owning a full on mac for dev&#8217;ing put me off spending a significant time at home coding for the device. That and it seemed like a lot of work to get going (probably because I use Linux almost all day so am not used to the Mac toolchain).</p>
<p>Working with android on linux has been a total pleasure. Mostly. I&#8217;m still getting re-used to the verbosity of java compared to my day-to-day python but the experiance has been a good one so far. I&#8217;ve basically been learning by looking at the sample apps supplied combined with a lot of googling and reading of android dev forums. There is a real wealth of documentation out there and there&#8217;s an absolute ton of general java code to solve most problems. This is where I&#8217;m at about a week into it (spending a couple of hours every few days on it).</p>
<p style="text-align: center;"><a href="http://jaymz.eu/wp-content/uploads/2010/05/tia-updated.png"><img class="aligncenter size-full wp-image-347" title="tia-updated" src="http://jaymz.eu/wp-content/uploads/2010/05/tia-updated.png" alt="" width="448" height="336" /></a></p>
<p>The HTTP posts are working now as is uploading a camera shot, you can store user/passwords and then it&#8217;ll do the form posts with that data. For now I have it just &#8220;logging&#8221; in to a dummy setup on my own server &#8211; that side is just some PHP for now. The real backend runs python (django), for now its just easier to run that data through some PHP on my blog server. The data for the views comes via a JSON array, that data is served up via python and is essentially just a REST interface to the TIA area. I&#8217;m mainly concentrating on just learning my way around the SDK but already I&#8217;m seeing that theres a lot of power in combining the android platform with django (and maybe django-pistons on top) to create rather powerful connected mobile apps.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaymz.eu/2010/05/crooked-tongues-tia-android-app-week-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Django vs Magento</title>
		<link>http://jaymz.eu/2009/09/django-vs-magento/</link>
		<comments>http://jaymz.eu/2009/09/django-vs-magento/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 18:53:27 +0000</pubDate>
		<dc:creator>jaymz</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[musing]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.jaymz.eu/?p=21</guid>
		<description><![CDATA[sigh&#8230; Recently I have had to (more than once) explain why we&#8217;re choosing Django to develop a e-commerce &#38; web app platform rather than using something off the shelf like Magento. I&#8217;ve heard lots of negative things regarding Magento and here&#8217;s what I&#8217;ve outlined in an email to PM&#8217;s etc which others might find useful [...]]]></description>
			<content:encoded><![CDATA[<p><strong>sigh&#8230;</strong> Recently I have had to (more than once) explain why we&#8217;re choosing Django to develop a e-commerce &amp; web app platform rather than using something off the shelf like Magento. I&#8217;ve heard lots of negative things regarding Magento and here&#8217;s what I&#8217;ve outlined in an email to PM&#8217;s etc which others might find useful if they have a similiar &#8220;justify it&#8221; experience.</p>
<p><a href="http://www.jaymz.eu/wp-content/uploads/2009/09/magentovsdjango.png"><img class="aligncenter size-full wp-image-42" title="magentovsdjango" src="http://www.jaymz.eu/wp-content/uploads/2009/09/magentovsdjango.png" alt="" width="400" height="220" /></a></p>
<p>The number one reason though I&#8217;d rather not work with Magento is that time and again developers express difficulty in making magento work <em>for them</em> and not their <em>magento consultant</em>.</p>
<p>Anywayz, I&#8217;m sure someone will take offense to this and I&#8217;m well aware I&#8217;m comparing a framework to a specific application but whatever&#8230;</p>
<p><em>Actually come to think of it, I&#8217;m not even comparing it really django, just listing some gripes and hate I&#8217;ve read/heard elsewhere</em></p>
<p><em><strong>Code extension &amp; extendability</strong></em></p>
<p>June 2009 : <a title="http://www.pickledshark.com/magento-ecommerce-complicated-bloated-brilliant/" href="/note_redirect.php?note_id=133611137778&amp;h=8cc168b9896df9708beaff3a13b7f07f&amp;url=http%3A%2F%2Fwww.pickledshark.com%2Fmagento-ecommerce-complicated-bloated-brilliant%2F" target="_blank">pickledshark.com</a></p>
<p>This guy is basically critical of the codebase being complex and difficult to work with. He ends with this:</p>
<blockquote><p>Due to the Zend/OOP/MVC influence on Magento it is impossible to follow the code. Classes are referenced dynamically, various aspects are contained in XML files and there is no clear flow that you can just debug through. The sheer volume of files and folders makes finding something unbelievably tedious.</p>
<p>Even the database is a minefield. In every other system I have used finding data is easy. In Magento, the use of EAV means that data is split amongst hundreds of abstract tables. Again, it doesn’t flow and it doesn’t make sense without a great deal of time developing a solid understanding of what they have done.</p>
<p>A final Cynical Note… Many people claim that the complexity of Magento is somewhat intentional. The <strong>profitability of Magento relys on consulting, technical support and installations</strong>. Making the codebase complex could mean that many developers will start out, get stuck and pay for help. If this is the intention of Varien then perhaps they have been very goal focused</p></blockquote>
<p>Hmm&#8230;&#8230; Another post here says that for most bits that arent in the free or enterprise version you can probably find a plugin to do it for you at magento-connect. Here&#8217;s something you&#8217;d imagine would be useful &#8220;get the lowest price free&#8221; and there is an extension for it. Problem being its $150.<br />
<a title="http://www.magentocommerce.com/extension/1931/lowest-price-free" href="/note_redirect.php?note_id=133611137778&amp;h=883e8b19570248a85daba3b1fad61e51&amp;url=http%3A%2F%2Fwww.magentocommerce.com%2Fextension%2F1931%2Flowest-price-free" target="_blank">Lowest Price Free plugin</a></p>
<p>The comments that I find over &amp; over are that the system itself is a nightmare to work from from a developer viewpoint unless you are some magento expert consulting for a fee (big surprise). Eg, here: (april 2009)</p>
<blockquote><p>The big thing for me right now is the <strong>documentation</strong>(specifically around customization) – it <strong>is nearly non-existent</strong>. The forums have TONS more questions that(sic.) answers, most of the Wiki articles focus on simple store administration or VERY simple theme level customizations (via CMS pages or edits to layouts).</p></blockquote>
<h4>Multiple products with similiar data &amp; attributes (eg sizes)</h4>
<p><a title="http://www.magentocommerce.com/boards/viewthread/36039/P15/" href="/note_redirect.php?note_id=133611137778&amp;h=b9edc18a90ca8ed02b9f6d5141f5cad6&amp;url=http%3A%2F%2Fwww.magentocommerce.com%2Fboards%2Fviewthread%2F36039%2FP15%2F" target="_blank">Last post 1 HOUR AGO!</a></p>
<p>A long discussion about how much of a ball-ache it is to manage multiple products that share a common base (i.e. different sizes of the same product). There is some talk about configurable products, grouped products etc but it seems that even all these still require duplication/entry of the same data per SKU:</p>
<blockquote><p>This problem is driving me nuts! I have a shop to build with over 100,000 possibilities of one single configurable product. Now… Could anyone tell me, how exactly I am supposed to manage this? I just can’t seemto find anyone dumb enough to add those products manually and I’m certainly not doing it myself! This is magento’s great weakness!</p></blockquote>
<h4>AJAXifing Templates and core features</h4>
<p><a title="http://www.magentocommerce.com/boards/viewthread/6204/P30/" href="/note_redirect.php?note_id=133611137778&amp;h=4b875f66596c49906bffc2f041237472&amp;url=http%3A%2F%2Fwww.magentocommerce.com%2Fboards%2Fviewthread%2F6204%2FP30%2F" target="_blank">Last post 3 Weeks ago</a></p>
<p>Lots of talk here trying to work out how to add ajax functionality to the magento site and surprise surprise, its not supported out of the box and rather complex for most people to try and work out. Instead, well:<br />
Vivendo has a great extension and it’s very affordable!</p>
<p>Whoop-ee! Who&#8217;s Vivendo? Oh yeah, the people that write the magento core.</p>
<h4>PCI DSS Compliance / Gift Certs / Logging of admin data</h4>
<p>For processing cards onsite your cart system should comply to the PCI-DSS regulations. Magento community does not and should be used in situations where you hand payment to another system like paypal or do not store card data on site if using a gateway. The Enterprise (the $8000/yr) system is scheduled to be certified to comply to PCI-DSS soon. Partly because the Enterprise version includes data encryption which the community one does not.</p>
<p>While a Django system would not be &#8220;out of the box&#8221; PCI-DSS compliant we would be writing the code to store attributes etc and would be able to add an encryption layer (such as 3DES or blowfish etc) to that data. It should also be noted that only the Enterprise edition supports admin logging, gift certs and some nice &#8220;extras&#8221; such as store credit.</p>
<p>Also the enterprise version is the only one to allow for a proper &#8220;walled garden&#8221; of catalogues so for example having a section of the store for dealers and not general public orders is not possible with the stock-standard magento. Its also not possible to have sub-admins (could only add new products for example) either something which the django admin site has out of the box (and is easily customizable/extended).</p>
<p><a title="http://www.magentocommerce.com/product/compare" href="/note_redirect.php?note_id=133611137778&amp;h=b76e833a4c1040fe454dd8d47bc6373c&amp;url=http%3A%2F%2Fwww.magentocommerce.com%2Fproduct%2Fcompare" target="_blank">Compare magento versions</a></p>
<h4>Licensing</h4>
<p>This is valid at the moment Magento Licesnsing:<br />
<em>As such, you must disclose any changes you make to the OSL 3.0-licensed copyrighted works whenever you distribute Magento or make your Magento store or software available over the web to a third party</em>.</p>
<p>We would probably require a commercial license for magento (i.e. enterprise) if we did not want to re-release any changes to core. Judging from the way people talk about working with magento you will probably end up having to modify core at some point. A Django solution would be completely our own code and even hacking django core, its licensed under BSD meaning commercial works need not release derivative works back to the original source branch.</p>
<p><a title="http://www.linfo.org/bsdlicense.html" href="/note_redirect.php?note_id=133611137778&amp;h=670924ca24d94b4dccd8f4a94e677dbf&amp;url=http%3A%2F%2Fwww.linfo.org%2Fbsdlicense.html" target="_blank">BSD License Terms</a><br />
Due to the extremely minimal restrictions of BSD-style licenses, software released under such licenses can be freely modified and used in proprietary (i.e., commercial) software for which the source code is kept secret.</p>
<h4>Payment Systems</h4>
<p>Magento may or may not support the gateway that we want to use. They have support for a lot (most with an additional fee for the module, seeing a pattern here?):</p>
<p><a title="http://www.magentocommerce.com/product/features/payment/view" href="/note_redirect.php?note_id=133611137778&amp;h=63677ab07eddae1d6be7cf7a1d264d20&amp;url=http%3A%2F%2Fwww.magentocommerce.com%2Fproduct%2Ffeatures%2Fpayment%2Fview" target="_blank">Supported magento payment systems</a></p>
<p>Paypal, google checkout, sagepay (protx) are supported with free/paid extensions. The protx one (updated for sage pay) is in beta at the minute and there are 3 pages worth of reviews pointing out problems people are having with it. This is an extra reason for concern for me personally &#8211; having to rely on a load of extensions written all by different people, some charged, some not just to get the core functioning. What happens if there&#8217;s a bug in one of them?</p>
<blockquote><p><em>This is a great extension and have Just upgraded to latest version and now it dont work? Using vewrsion 1.3.1.1 beta.</em></p></blockquote>
<h4>Fin</h4>
<p>Ok, thats probably enough for now. Main point being that this system is customisable &#8211; for a fee. If they are mainly concerned about linking systems together then they really need to understand that the data can come as and how they want it. If they want XML of all their orders based on a SKU then we can provide that. If they have custom systems or expect data in such a way then we will fit output to that schema! It still feels like they think magento is this software like microsoft office that is going to somehow solve a load of problems off the bat.</p>
<p>One of the main things for me is that Magento is a dual licensed, essentially paid for system with a big consultant/community that work to push magento. Django is an open source BSD licensed framework built for developers to develop web applications on. Django does not offer paid-for licensed versions, its in django&#8217;s interest to have as much and as transparent documentation as possible. For Magento its not quite in their interest to have that same level of documentation, something which seems to be reflected when you read about developers experiences trying to extend it. Invariably it ends with a &#8220;magento expert&#8221; doing the work or the person struggling to fix it and ending up hacking core or finding some extension that just about does what they want and they live with it.</p>
<p>I know I&#8217;m going to end up having some &#8220;out of the ordinary&#8221; use cases when it comes to discounts, cart functioning and products themselves and the idea of working with magento does not thrill me. When you see <a title="http://stackoverflow.com/questions/773562/magento-orm-documentation" href="/note_redirect.php?note_id=133611137778&amp;h=28302486bca21f0a74cd22ea3f421b86&amp;url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F773562%2Fmagento-orm-documentation" target="_blank">posts on stackoverflow</a>asking if theres any other documentation <em>but the source code</em> for the <a title="http://en.wikipedia.org/wiki/Object-relational_mapping" href="/note_redirect.php?note_id=133611137778&amp;h=f308918e4e067b41a2719285f00ec567&amp;url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FObject-relational_mapping" target="_blank"><strong>ORM</strong></a> then alarm bells ring. Especially when you&#8217;re used to the sort of quality &amp; thorough documentation <a title="http://docs.djangoproject.com/en/dev/" href="/note_redirect.php?note_id=133611137778&amp;h=f8ba0cd3f1f5eb70413ba832e2d8b80c&amp;url=http%3A%2F%2Fdocs.djangoproject.com%2Fen%2Fdev%2F" target="_blank">django provides</a></p>
<p><strong>End rant!</strong> So yeah, I&#8217;m not the worlds biggest fan of magento. And I&#8217;ve not even touched on the actual quantity &amp; scale of the db tables it installs on a fresh version. Magento fanatics please keep your &#8220;its brilliant &amp; you are a knob&#8221; mail to yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaymz.eu/2009/09/django-vs-magento/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

