<?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"
	>

<channel>
	<title>Redi for Life</title>
	<atom:link href="http://blog.redinnovation.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.redinnovation.com</link>
	<description>What it feels like working in Web 2.0</description>
	<pubDate>Mon, 30 Jun 2008 21:23:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Relativity of time - shortcomings in Python datetime, and workaround</title>
		<link>http://blog.redinnovation.com/2008/06/30/relativity-of-time-shortcomings-in-python-datetime-and-workaround/</link>
		<comments>http://blog.redinnovation.com/2008/06/30/relativity-of-time-shortcomings-in-python-datetime-and-workaround/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 12:39:10 +0000</pubDate>
		<dc:creator>ztane</dc:creator>
		
		<category><![CDATA[python]]></category>

		<category><![CDATA[solution]]></category>

		<category><![CDATA[datetime]]></category>

		<category><![CDATA[i18n]]></category>

		<category><![CDATA[internationalization]]></category>

		<category><![CDATA[localization]]></category>

		<category><![CDATA[mxdatetime]]></category>

		<category><![CDATA[pytz]]></category>

		<category><![CDATA[timedelta]]></category>

		<category><![CDATA[timezone]]></category>

		<category><![CDATA[timezone support]]></category>

		<category><![CDATA[utc]]></category>

		<category><![CDATA[zope]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/?p=47</guid>
		<description><![CDATA[Recently I found out that the standard library support for date and time calculations in Python is not quite as able as I needed. It turned out that the superficial leanness and simplicity of Python&#8217;s datetime module bit hard back sooner than you expected. Unfortunately, looking for replacements, I found out that the existing replacement [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I found out that the standard library support for date and time calculations in Python is not quite as able as I needed. It turned out that the superficial leanness and simplicity of Python&#8217;s datetime module bit hard back sooner than you expected. Unfortunately, looking for replacements, I found out that the existing replacement modules have some issues on their own. This blog entry highlights various problems with the current Python datetime implementation. A partial solution will be offered, too.</p>
<h1>Basics of time zones</h1>
<p>Time zones are a relatively new invention in the long history of measuring time. During most of the 19th century pretty much each European town had its own definition of local time. It was not until 1880 that Greenwich Mean Time was officially made the standard time in the Great Britain; much of the remaining world had adopted the idea by the 1920s. Today, all countries in the world use standard time zones, though not every one is using full-hour offsets to the GMT as it was originally conceived.</p>
<p>The concept of summer time (daylight saving time in AmE) complicates things further: for example in European Union the member states will switch to summer time on the last Sunday of March at 01:00 GMT exact. The summer time lasts until the last Sunday of October, 01:00 GMT. In Finland, this means that this year on 30th March the official time stepped from <strong>02:59:59 EET to 04:00:00 EEST </strong><code class="literal">in an instant</code>. Likewise, on 26th October this year, the summer time clocks will tick up to <strong>03:59:59 EEST</strong>, and on the<strong> </strong>next second the local time will be<strong> </strong><strong>03:00:00 EET</strong>; and almost a hour later, <strong>03:59:59 EET.</strong> Thus, the number of seconds between <strong>02:59:59</strong> and <strong>04:00:00</strong> on a single day might be 1, 3601, or 7201; the difference between 02:59:59 and 03:00:01 might likewise be 2 or 3602 seconds&#8230; or even undefined.</p>
<p>To alleviate obvious confusions and misunderstandings, a reference time scale can be used for calculations that concern different time zones. The obvious choice is Coordinated Universal Time (UTC) that replaced Greenwich Mean Time as the standard reference time scale for civilian applications in 1972. During the Internet era UTC has become increasingly important.</p>
<h1>Time zones in Python - welcome to hell</h1>
<p>Suppose you have a shared web calendar application that is used by people all over the world. Each user wants to view the calendar in their respective local time, and you wish to use UTC on the server. The server has been set up with Europe/Helsinki as the local timezone. And you wish to use the facilities provided by the Python standard library modules. Simple date arithmetic would be needed - what could possibly go wrong? You will soon find out that it is not at all simple. Actually it is annoyingly complicated:</p>
<pre>&gt;&gt;&gt; from datetime import datetime
&gt;&gt;&gt; dt = datetime.now()
&gt;&gt;&gt; dt
datetime.datetime(2008, 6, 19, 14, 51, 41, 296552)
&gt;&gt;&gt; # ok, it prints the local time. Let's try to
&gt;&gt;&gt; # convert it to UTC time...
&gt;&gt;&gt; dt.utctimetuple()
(2008, 6, 19, 14, 51, 41, 3, 171, 0)
&gt;&gt;&gt; # wait, ahem... 14:51:41... that can't be right...
&gt;&gt;&gt; # the docs say: utctimetuple(...)
&gt;&gt;&gt; #     Return UTC time tuple, compatible with time.localtime().
&gt;&gt;&gt; #
&gt;&gt;&gt; # ok.. so UTC time tuple, compatible with localtime...
&gt;&gt;&gt; # WTF?? my local time zone is not UTC... strangely enough
&gt;&gt;&gt; # the last field in the tuple, "is_dst", is 0, or false...
&gt;&gt;&gt;&gt;# I thought June was in summer...
&gt;&gt;&gt;
&gt;&gt;&gt; # Ok, the factory method I need seems to be utcnow
&gt;&gt;&gt; # - that way I can get the time in UTC?)
&gt;&gt;&gt; datetime.utcnow()
datetime.datetime(2008, 6, 19, 11, 59, 9, 750844)
&gt;&gt;&gt; # fair enough, UTC time.

&gt;&gt;&gt; # Let's try simple date arithmetic: the difference
&gt;&gt;&gt; # between now... and now...
&gt;&gt;&gt; datetime.now() - datetime.utcnow()
datetime.timedelta(0, 10799, 999984)
&gt;&gt;&gt; # Hmm... now did that statement really
&gt;&gt;&gt; # take 3 hours to execute?</pre>
<p>The reason for these anomalies is that without any time zone information, instances of the datetime class behave as if they stored time in UTC. For our purposes this is unacceptable: if a user of the hypothetical calendar application proposes a meeting 2 hours from now, be it 17:15 EEST or 14:15 UTC, <code>meeting.start - datetime.now()</code> should on this very moment result in 2 hours regardless of the time zone of the user asking it.</p>
<p>While there are several freely available Python modules that provide date and time calculations, like Zope&#8217;s DateTime, the problem with them is that none of them is really compatible with datetime interface - if you use code that expects datetime instances, Zope&#8217;s DateTime objects will not help you. Some of the replacement modules, like mxDateUtil seems to use dubious date arithmetic, and are not really useful either. Clearly, we have to either fix the python datetime class somehow, or provide a compatible implementation that works as expected.</p>
<h1>Fixing datetime</h1>
<p>Fortunately, Python datetimes can be made time zone aware, by supplying an instance of tzinfo in the constructor. Unfortunately enough, the Python standard library does not provide any concrete implementations. Dang! Enters: pytz, a Python library that supplies hundreds of concrete time zone definitions.</p>
<pre>&gt;&gt;&gt; import pytz
&gt;&gt;&gt; eurhel = pytz.timezone("Europe/Helsinki")
&gt;&gt;&gt; localt = datetime.now(eurhel)
&gt;&gt;&gt; utct = datetime.now(pytz.utc)
&gt;&gt;&gt; utct - localt
datetime.timedelta(0, 0, 3410)</pre>
<p>Works as expected. And, utct - datetime.utcnow() fails with &#8220;TypeError: can&#8217;t subtract offset-naive and offset-aware datetimes&#8221; - which is good, as it would not yield sensible results. However, a look under the hood reveals that something is fundamentally wrong:</p>
<pre>&gt;&gt;&gt; datetime.datetime.now()
datetime.datetime(2008, 6, 23, 18, 2, 31, 101025,
        tzinfo=&lt;DstTzInfo 'Europe/Helsinki' EEST+3:00:00 DST&gt;)
&gt;&gt;&gt; datetime.datetime(2008, 6, 23, 18, 2, 31, 101025, eurhel)
datetime.datetime(2008, 6, 1, 18, 0, tzinfo=&lt;DstTzInfo 'Europe/Helsinki' HMT+1:40:00 STD&gt;)
&gt;&gt;&gt; # after a minute...
&gt;&gt;&gt; datetime.datetime(2008, 6, 23, 18, 2, 31, 101025, eurhel) - datetime.datetime.now(eurhel)
datetime.timedelta(0, 4687, 688091)</pre>
<p>That&#8217;s right, the datetime object created by a call to datetime.datetime constructor now seems to think that Finland uses the ancient &#8220;Helsinki Mean Time&#8221; which was obsoleted in the 1920s. The reason for this behaviour is clearly documented on the pytz page: it seems the Python datetime implementation never asks the tzinfo object what the offset to UTC on the given date would be. And without knowing it pytz seems to default to the first historical definition. Now, some of you fellow readers could insist on the problem going away simply by defaulting to the latest time zone definition. However, the problem would still persist: For example, Venezuela switched to GMT-04:30 on 9th December, 2007, causing the datetime objects representing dates either before, or after the change to become invalid.</p>
<p>The solution offered by pytz pages is to use the normalize and localize methods of pytz tzinfo instances, however this renders the whole datetime system too cumbersome to use. As I wanted to use datetime objects with time zones as easily as possible, I had to subclass the python datetime implementation and hack some internal aspects of it. The module, fixed_datetime also contains a method, set_default_timezone, to allow mimicking of the naive datetime objects; unlike ordinary datetime objects, fixed_datetime.datetime objects are never &#8216;naive&#8217;, but many of the methods will default to the time zone set by the said method.</p>
<pre>&gt;&gt;&gt; import fixed_datetime

&gt;&gt;&gt; # set default timezone...
&gt;&gt;&gt; fixed_datetime.set_default_timezone("Europe/Helsinki")

&gt;&gt;&gt; # uses default timezone...
&gt;&gt;&gt; fixed_datetime.datetime.now()
fixed_datetime.datetime(2008, 6, 23, 18, 33, 20, 525486,
        tzinfo=&lt;DstTzInfo 'Europe/Helsinki' EEST+3:00:00 DST&gt;)

&gt;&gt;&gt; # also works correctly
&gt;&gt;&gt; fixed_datetime.datetime(2008, 6, 23, 18, 33, 20, 525486)
fixed_datetime.datetime(2008, 6, 23, 18, 33, 20, 525486,
        tzinfo=&lt;DstTzInfo 'Europe/Helsinki' EEST+3:00:00 DST&gt;)

&gt;&gt;&gt; # UTC timestamps returned with UTC tzinfo
&gt;&gt;&gt; fixed_datetime.datetime.utcnow()
fixed_datetime.datetime(2008, 6, 23, 15, 37, 44, 777729, tzinfo=&lt;UTC&gt;)

&gt;&gt;&gt; # subtraction still works correctly!
&gt;&gt;&gt; utcdt = fixed_datetime.datetime.utcnow()
&gt;&gt;&gt; heldt = fixed_datetime.datetime.now()
&gt;&gt;&gt; heldt - utcdt
datetime.timedelta(0, 5, 495702)</pre>
<p>As a bonus, fixed_datetime.datetime contains methods to convert datetimes from ISO 8601 format. The method support parsing the time zone field, too:</p>
<pre>&gt;&gt;&gt; fixed_datetime.datetime.fromisoformat("20081010T010203+0500")
fixed_datetime.datetime(2008, 10, 10, 1, 2, 3, tzinfo=&lt;UTC+05:00&gt;)

&gt;&gt;&gt; fixed_datetime.datetime.fromisoformat("2008-10-10 01:02:03Z")
fixed_datetime.datetime(2008, 10, 10, 1, 2, 3, tzinfo=&lt;UTC&gt;)

&gt;&gt;&gt; # fractional hours, decimal comma, odd timezone
&gt;&gt;&gt; fixed_datetime.datetime.fromisoformat("2008-10-10 01,0341666667-04:37")
fixed_datetime.datetime(2008, 10, 10, 1, 2, 3,
        tzinfo=&lt;UTC-04:37&gt;)

&gt;&gt;&gt; fixed_datetime.datetime.today().isoformat(' ')
'2008-06-23 18:54:32+03:00'

&gt;&gt;&gt; # isoformat supports short format, too
&gt;&gt;&gt; fixed_datetime.datetime.now().isoformat(short=True)
'20080623T185303.489792+0300'

&gt;&gt;&gt; # addition across DST boundary works as expected:
&gt;&gt;&gt; before = fixed_datetime.datetime(2008, 10, 26, 2, 0, 0)
&gt;&gt;&gt; before
fixed_datetime.datetime(2008, 10, 26, <strong>2</strong>, 0, tzinfo=
        &lt;DstTzInfo &#8216;Europe/Helsinki&#8217; <strong>EEST+3:00:00</strong> <strong>DST</strong>&gt;)

&gt;&gt;&gt; # now, add 2 hours
&gt;&gt;&gt; before + fixed_datetime.timedelta(seconds=7200)
fixed_datetime.datetime(2008, 10, 26, <strong>3</strong>, 0, tzinfo=
        &lt;DstTzInfo &#8216;Europe/Helsinki&#8217; <strong>EET+2:00:00</strong> <strong>STD</strong>&gt;)</pre>
<p>You can download the said module below.</p>
<h1>Remaining issues</h1>
<p>Not every remaining issue is solved. Fixed datetime still does not accept &#8220;24&#8243; as hour value (mandated by ISO standard), and will throw an exception on positive leap seconds. Fixed datetime is much slower than the python implementation - many of the operations need to create intermediate 2 or 3 datetime instances.</p>
<p>Sadly it seems that Java got it right: having one class (<a title="java.util.Date documentation" href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html">Date</a>) that stores times in UTC seconds relative to Unix Epoch, and subclasses of abstract <a title="java.util.Calendar documentation" href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html">Calendar</a> class that deal with getting and setting individual components and date arithmetic in a localized way would indeed be the best long-term solution. To some Java&#8217;s date and calendar handling would seem overly complicated, to me it is the simplest way of representing the complex world of different calendars, time zones and other aspects of time keeping. If only someone could persuade Python devs to add something similar to the standard library&#8230;</p>
<h1>Download</h1>
<p>Download <a href="http://blog.redinnovation.com/wp-content/uploads/2008/06/fixed_datetime.py">fixed_datetime.py</a>, released under 3-clause BSD license.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.redinnovation.com/2008/06/30/relativity-of-time-shortcomings-in-python-datetime-and-workaround/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Logging with LogMan</title>
		<link>http://blog.redinnovation.com/2008/06/23/logging-with-logman/</link>
		<comments>http://blog.redinnovation.com/2008/06/23/logging-with-logman/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 14:55:58 +0000</pubDate>
		<dc:creator>Jussi Toivola</dc:creator>
		
		<category><![CDATA[development tools]]></category>

		<category><![CDATA[pys60]]></category>

		<category><![CDATA[symbian]]></category>

		<category><![CDATA[c++]]></category>

		<category><![CDATA[logging]]></category>

		<category><![CDATA[logman]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[rdebug]]></category>

		<category><![CDATA[s60]]></category>

		<category><![CDATA[serial]]></category>

		<category><![CDATA[series 60]]></category>

		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/?p=48</guid>
		<description><![CDATA[This is my first post on our company blog and I thought I&#8217;d tell you something about LogMan, which is developer&#8217;s utility for getting logging messages from Symbian device over a USB cable. It is written by me and mostly on my own time. I started the project because I had to do a Symbian [...]]]></description>
			<content:encoded><![CDATA[<p>This is my first post on our company blog and I thought I&#8217;d tell you something about <a href="http://code.google.com/p/logman-for-symbian/">LogMan</a>, which is developer&#8217;s utility for getting logging messages from Symbian device over a USB cable. It is written by me and mostly on my own time. I started the project because I had to do a Symbian excercise for university course and I thought I&#8217;d do something useful instead of quickly tinkering something small and easy.</p>
<p>LogMan supports both C++ and Python. With LogMan, you can send data to the same location from Python and C++ in real-time instead of using log file(s). Browsing through multiple log files can be tedious and you can&#8217;t see the debug output while using your application, because on Symbian you must read the file after the debugging session - Symbian cannot share opened files between applications. It is also possible that you create too much log and you run out of Phone internal memory. LogMan helps by removing the use of log files and you never run out of disk space because messages can be stored directly to PC. On simulator, the messages are also sent to <a href="http://wiki.forum.nokia.com/index.php/How_to_use_RDebug">RDebug</a> (%TEMP%\epocwind.out). Surprisingly I have not seen a Python module, which would enable use of RDebug. Even though it is very easy to implement. With RDebug, there is no need to open a serial port on simulator for reading the logging messages.</p>
<p>Of course, I tried to use RDebug on device first, but I never got it working. I also tried <a href="http://www.forum.nokia.com/document/CDL_Extension_S60_3rd_Ed_FP2/GUID-C89505CF-D5FE-4C89-95D4-692443563021/html/classREcmt.html">REcmt</a>, which is supported on S60 only and the service just kept on crashing on my phone. This is why I decided to write LogMan. Plus both are closed software, which effectively prevented me from fixing the problems.</p>
<p>Just wondering what kind of benefit Symbian or Nokia gets from keeping development tools such as these closed? What is there so secret about them? It didn&#8217;t take me very long to write the first working version. *sigh*</p>
<p>The use of LogMan is similar to RDebug. There are static class methods, which are a bit slower but easier, and instance methods. Check the project&#8217;s <a href="http://code.google.com/p/logman-for-symbian/">homepage </a> for more examples.</p>
<p><code><br />
#include "LogMan.h" //RLogMan<br />
RLogMan::Log( _L("Hello world ") );<br />
</code></p>
<p>I recently added a new feature for LogMan, which allows you to log stack and heap usage of the current thread with one function. When you are unsure about your heap or stack usage, these might come handy. Of course there is some memory used when calling these so take that into consideration. Python can access MemoryInfo only, which logs both stack and heap (Well, I got a bit lazy at that point). There are equivalent macros for these, so check them out from &#8220;logmanutils.h&#8221;.</p>
<p><code><br />
// Store this as a member of your class, for example<br />
RLogMan logman;</code></p>
<p>logman.HeapInfo();<br />
logman.StackInfo();<br />
logman.MemoryInfo(); // Both stack and heap<br />
logman.Close();</p>
<p>The output from MemoryInfo is something like this:<br />
<code><br />
StackInfo<br />
Free:1039000, Used:9576, Size:1048576<br />
HeapInfo<br />
Free:25856, Used:101004, Size:126860<br />
</code></p>
<h2>Browser for PyS60</h2>
<p>I have been trying, unsuccessfully, to get Browser Control working on PyS60. In a nutshell, <a href="http://www.forum.nokia.com/document/Cpp_Developers_Library/GUID-96C272CA-2BED-4352-AE7C-E692B193EC06/html/classCBrCtlInterface.html">CBrCtlInterface</a> wrapper for Python. I have developed it against <a href="https://code.launchpad.net/~jussi-toivola/pys60community/browserbranch">PyS60Community</a> version in Launchpad. See /src/appui/appuifw/. I have used LogMan extensively to debug the extension so if you want a real example, check out &#8220;browsercontrol.cpp&#8221;.</p>
<p>Browser Control would allow one to embed a browser into his PyS60 application, which would be quite cool. No need to do user interfaces with &#8220;appuifw&#8221;, which is not very portable. With Browser Control, one could create his user interface with html and javascript, which are a lot more portable indeed. Less work leads to more time. And what is time?&#8230; it&#8217;s money. Or so I have heard. And being able to handle events with Python instead of C++ is another bonus.</p>
<p>Unfortunately, the API is not very stable as you can see by searching for &#8220;CBrCtlInterface&#8221; at Forum Nokia. The browser worked fine on the simulator with small pages such as &#8220;www.google.com&#8221;, but it crashed miserably with larger pages. The crash happens in browsercontrol.dll when calling e32.Ao_sleep() in Python. On device it was unable to open any page and crashed instantly when trying to load one. With LogMan, I was able to verify that the crash happened in e32.Ao_sleep() on device also. This reminds me to test on device all the time, which I didn&#8217;t do for the first versions. But this is why I added the memory logging feature to LogMan, but it only revealed that I was not out of stack or heap. At least not before the browser started to mess around.</p>
<p>I tried to compile the WebKit myself to see what is going on, but the build instructions didn&#8217;t work and the build scripts are written in Perl(my eyes started to hurt). What a mess. I don&#8217;t wonder anymore if there are bugs in browsercontrol.dll. I finally gave up because my idea pool dried up. Any help getting the wrapper working would be very much appreciated.</p>
<h2>Plans for LogMan</h2>
<p>I&#8217;m planning to add remote shell interface so that you could control your phone from PC. I want access to the file system first. Transfer files, list folders and such. If you have TCB rights ( or hacked phone ) you can speed up development remarkably by simply replacing your binaries in \sys\bin or your Python files with new versions. No need to install sis files and fiddle with certificates and play with memory cards. It would be so nice&#8230; I can use 1 day in a week for a personal project so this may happen in near future <img src='http://blog.redinnovation.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.redinnovation.com/2008/06/23/logging-with-logman/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Plone, KSS, Javascript, field validation and the cup of WTF</title>
		<link>http://blog.redinnovation.com/2008/06/12/plone-kss-javascript-field-validation-and-the-cup-of-wtf/</link>
		<comments>http://blog.redinnovation.com/2008/06/12/plone-kss-javascript-field-validation-and-the-cup-of-wtf/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 00:43:39 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
		
		<category><![CDATA[Plone]]></category>

		<category><![CDATA[ajax]]></category>

		<category><![CDATA[archetypes]]></category>

		<category><![CDATA[bug]]></category>

		<category><![CDATA[debug]]></category>

		<category><![CDATA[debugging]]></category>

		<category><![CDATA[field]]></category>

		<category><![CDATA[heisenbug]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[kss]]></category>

		<category><![CDATA[validation]]></category>

		<category><![CDATA[zope]]></category>

		<category><![CDATA[zope 3]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/?p=46</guid>
		<description><![CDATA[Knowledge does hurt. Today I had my sweet cup of WTF. We are developing a medical database based on Plone 3.1. It uses very advanced AJAX framework called KSS - basically you can avoid the pain of writing pure Javascript by crafting special CSS like stylesheets which bind server-side Python code to any Javascript event. [...]]]></description>
			<content:encoded><![CDATA[<p>Knowledge <em>does</em> hurt. Today I had my sweet cup of WTF. We are developing a medical database based on Plone 3.1. It uses very advanced AJAX framework called <a href="http://kssproject.org/">KSS</a> - basically you can avoid the pain of writing pure Javascript by crafting special CSS like stylesheets which bind server-side Python code to any Javascript event. This makes AJAX programming a joy. You can easily combine server-side logic with user interface events, like field validation.</p>
<p>Well&#8230; then there was an error. KSS validation was not working for the text fields on a certain pages&#8230;. or it did sometimes. We were not sure. This is so called <a href="http://en.wikipedia.org/wiki/Heisenbug#Heisenbugs">Heisenbug</a>. I armed myself with sleepy eyes, Firebug and a lot of energy drinks.</p>
<p>I saw a KSS error in the Firebug log window and failed HTTP POST in the server logs.</p>
<p style="padding-left: 30px;"><strong> Invalid request.</strong></p>
<p style="padding-left: 30px;">The parameter, <em>value,</em> was omitted from the request.</p>
<p>Looks like the field value was not properly posted for the field validation.</p>
<p>The first thing was locate the error and get function traceback for the messy situation. Unfortunately Firefox Javascript engine or Firebug cannot show tracebacks properly&#8230; <a href="http://www.microsoft.com/express/vwd/">the grass is so much greener on the other side of the fence</a>. So I had to manually search through the codebase by manually plotting console.log() calls here and there.</p>
<p>Finally I thought I pinpointed the cause of the failure. By shaking finger (excitement, tireness and all that extra caffeinen from energy drinks), I opened the Javascript file just to realize why Javascript is utterly utterly shitty and why no sane person wants to do low level Javascript development. If ECMA standard committee had been clever and had been able to enforce anything long time ago, the following piece could be replaced with one function call.</p>
<pre>fo.getValueOfFormElement = function(element) {
    // Returns the value of the form element / or null
    // First: update the field in case an editor is lurking
    // in the background
    this.fieldUpdateRegistry.doUpdate(element);
    if (element.disabled) {
        return null;
    }
    // Collect the data
    if (element.selectedIndex != undefined) {
        // handle single selects first
        if(!element.multiple) {
                if (element.selectedIndex &lt; 0) {
                    value="";
                } else {
                    var option = element.options[element.selectedIndex];
                    // on FF and safari, option.value has the value
                    // on IE, option.text needs to be used
                    value = option.value || option.text;
                }
        // Now process selects with the multiple option set
        } else {
            var value = [];
            for(i=0; i&lt;element.options.length; i++) {
                var option = element.options[i];
                if(option.selected) {
                    // on FF and safari, option.value has the value
                    // on IE, option.text needs to be used
                    value.push(option.value || option.text);
                }
            }
        }
    // Safari 3.0.3 no longer has &#8220;item&#8221;, instead it works
    // with direct array access []. Although other browsers
    // seem to support this as well, we provide checking
    // in both ways. (No idea if item is still needed.)
    } else if (typeof element.length != &#8216;undefined&#8217; &amp;&amp;
        ((typeof element[0] != &#8216;undefined&#8217; &amp;&amp;
        element[0].type == &#8220;radio&#8221;) ||
        (typeof element.item(0) != &#8216;undefined&#8217; &amp;&amp;
        element.item(0).type == &#8220;radio&#8221;))) {
        // element really contains a list of input nodes,
        // in this case.
        var radioList = element;
        value = null;
        for (var i=0; i &lt; radioList.length; i++) {
            var radio = radioList[i] || radioList.item(i);
            if (radio.checked) {
                value = radio.value;
            }
        }
    } else if (element.type == &#8220;radio&#8221; || element.type == &#8220;checkbox&#8221;) {
        if (element.checked) {
           value = element.value;
        } else {
            value = null;
        }
    } else if ((element.tagName.toLowerCase() == &#8216;textarea&#8217;)
               || (element.tagName.toLowerCase() == &#8216;input&#8217; &amp;&amp;
                    element.type != &#8217;submit&#8217; &amp;&amp; element.type != &#8216;reset&#8217;)
              ) {
        value = element.value;
    } else {
        value = null;
    }
    return value;
};
</pre>
<p>It turned out that the element in this case was an empty list of radio buttons. When you are tab keying through a radio button group without any value selected, like in the case a content object is just created, KSS validation is triggered even though there is no value in any of the radio buttons. This makes KSS think the value is null and it does not properly handle the situation. This does not cause any user visible effects unless you have Javascript debugging on (Firebug + debugging mode in Plone&#8217;s Javascript registry).</p>
<p>But this was not the bug I was looking for. It was just masking the original bug, because I had an empty radio button group next to the text field whose validation was not correctly done. More server side debugging&#8230;</p>
<p>I inserted some funky debug prints to Archetypes.Field.validate_validators():</p>
<pre>validate_validators()</pre>
<pre>Calling validators:(('isEmptyNoError', V_SUFFICIENT), ('validDecRange03', V_REQUIRED))</pre>
<p>We can see that not triggered validator, validDecRange03, is still with us. Then I add more debug prints to see where things go wrong, this time to to Products.validation.chain.__call__.</p>
<pre>Calling validators:(('isEmptyNoError', V_SUFFICIENT), ('validDecRange03', V_REQUIRED))
Name:isEmptyNoError value:234234234234234234234234234232342342342344534232342344234534554 result:True</pre>
<p>Ok - we have a case here. isEmptyNoError validator is executed before our custom validator. Since this validator is flagged as &#8220;sufficient&#8221; other validators are not evaluated. I think this has not been the case before and our validator have worked properly&#8230; maybe there was API change in Plone 3.1 which broke the things?</p>
<p>After digging and digging and digging I found <a href="https://dev.plone.org/archetypes/ticket/591">this 4 years old bug</a>. Let&#8217;s open the famous isEmptyNoError source code in Products.validation.validators.EmptyValidator:</p>
<pre>class EmptyValidator:
    __implements__ = IValidator

    def __init__(self, name, title='', description='', showError=True):
        self.name = name
        self.title = title or name
        self.description = description
        self.showError = showError

    def __call__(self, value, *args, **kwargs):
        isEmpty  = kwargs.get('isEmpty', False)
        instance = kwargs.get('instance', None)
        field    = kwargs.get('field', None)

        # XXX: This is a temporary fix. Need to be fixed right for AT 2.0
        #      content_edit / BaseObject.processForm() calls
        #      widget.process_form a second time!
        if instance and field:
            widget  = field.widget
            request = getattr(instance, 'REQUEST', None)
            if request and request.form:
                form   = request.form
                result = widget.process_form(instance, field, form,
                                             empty_marker=_marker,
                                             emptyReturnsMarker=True)
                if result is _marker or result is None:
                    isEmpty = True

        if isEmpty:
            return True
        elif value == '' or value is None:
            return True
        else:
            if getattr(self, 'showError', False):
                return ("Validation failed(%(name)s): '%(value)s' is not empty." %
                       { 'name' : self.name, 'value': value})
            else:
                return False
</pre>
<p>There is my WTF. Or XXX - thanks for the kisses. My guess is that because KSS validation is executed in special context, the magical REQUEST might not be there. The &#8220;is sufficient&#8221; validator fails because of the some sort of god forgotten magic and thus <strong>all custom validators fail in KSS when the field is not required</strong>.</p>
<p>The workaround: I add my own greetings to the code:</p>
<pre>        # XXX: This is a temporary fix. Need to be fixed right for AT 2.0
        #      content_edit / BaseObject.processForm() calls
        #      widget.process_form a second time!
        if instance and field:
            widget  = field.widget
            request = getattr(instance, 'REQUEST', None)

            # XXX: Whatever this all does, it does not work for KSS validation
            # requests and we should ignore this
            if "fieldname" in request:
              return False

            if request and request.form:
                form   = request.form
                result = widget.process_form(instance, field, form,
                                             empty_marker=_marker,
                                             emptyReturnsMarker=True)
                if result is _marker or result is None:
                    isEmpty = True
</pre>
<p>If Zope 3 drives you smoking Plone 3 drives me drinking. No wonder newbies steer away from Plone - if you hadn&#8217;t been armed with 8 years of web development experience you would never have figured out what&#8217;s going on with such a simple thing as adding a custom validator. <a href="http://dev.plone.org/plone/ticket/7589#comment:4">A comment added to the bug tracker</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.redinnovation.com/2008/06/12/plone-kss-javascript-field-validation-and-the-cup-of-wtf/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Viivi &#038; Wagner strip scraper</title>
		<link>http://blog.redinnovation.com/2008/05/07/viivi-wagner-strip-scaper/</link>
		<comments>http://blog.redinnovation.com/2008/05/07/viivi-wagner-strip-scaper/#comments</comments>
		<pubDate>Tue, 06 May 2008 22:33:22 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
		
		<category><![CDATA[python]]></category>

		<category><![CDATA[beuatifulsoap]]></category>

		<category><![CDATA[challenge]]></category>

		<category><![CDATA[comic]]></category>

		<category><![CDATA[downloader]]></category>

		<category><![CDATA[ocr]]></category>

		<category><![CDATA[programming language]]></category>

		<category><![CDATA[scaper]]></category>

		<category><![CDATA[spider]]></category>

		<category><![CDATA[strip]]></category>

		<category><![CDATA[viivi ja wagner]]></category>

		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/?p=40</guid>
		<description><![CDATA[I wrote this little script as a mental exercise and to prove the power of Python programming language. If anyone accepts the challenge, I&#8217;d like to see submissions in other programming langauges  
For the foreigners: this is the best comic in Finland, so I hope you&#8217;ll get translations soon! It tells about the relationship [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote this little script as a mental exercise and to prove the power of Python programming language. If anyone accepts the challenge, I&#8217;d like to see submissions in other programming langauges <img src='http://blog.redinnovation.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>For the foreigners: this is the best comic in Finland, so I hope you&#8217;ll get translations soon! It tells about the relationship of a woman and a pig (sic) reflecting the deepest shadows of Finnish social life.</p>
<pre>"""
	Creats local mirror from Viivi &amp; Wagner strips by fetching all of them from hs.fi.

	Will create downloaded strips as
		2004/1.1.2004.gif
		2004/2.1.2004.gif
		...
		until today

	Try this in C++!

	Motivation: No one has build Viivi &amp; Wagner search engine with speech bubble OCR support
	and I desperately wanted to find "Kottarainen lentaa korvaan" strip for my gf.

	Time to complete: 20 min.

"""

__docformat__ = "epytext"
__author__ = "Mikko Ohtamaa"
__license__ = "BSD"
__copyright__ = "2008 Mikko Ohtamaa"

import os
import re
import urllib
from BeautifulSoup import BeautifulSoup

# 1.1.2004 start page
url = "http://www.hs.fi/viivijawagner/1073386660690"

# Loop until there is no longer next link
while True:
	stream = urllib.urlopen(url)
	html = stream.read()
	stream.close()
	soup = BeautifulSoup(html)

	# Parse strip date from contents
	date = None

	# Find strip date, which is next to a title
	h1 = soup.findAll(text="Viivi ja Wagner")
	# Should be present always
	date = h1[0].parent.parent.p.string

	print &#8220;Fetching &#8221; + date

	# Scrape strip
	strip = soup.findAll(&#8221;div&#8221; , { &#8220;class&#8221; : &#8220;strip&#8221; })
	img = strip[0].img

	stream = urllib.urlopen(img["src"])
	data = stream.read()
	stream.close()

	# For each year, give a new folder to avoid file system stress
	# (lotsa files in a folder kill poor Gnome)
	day, month, year = date.split(&#8221;.&#8221;)
	folder = year

	if not os.path.exists(folder):
		os.mkdir(folder)	

	# Store contents
	fname = os.path.join(folder, date + &#8220;.gif&#8221;)
	f = open(fname, &#8220;wb&#8221;)
	f.write(data)
	f.close()

	# Find next url, it is a containing one img tag
	img = soup.findAll(alt=&#8221;seuraava&#8221;)
        if len(img) == 0:
             break
	a = img[0].parent
	url = a["href"]
</pre>
<h2>See preview</h2>
<p><a href="http://blog.redinnovation.com/wp-content/uploads/2008/05/screenshot-2004-file-browser1.png"><img class="alignnone size-thumbnail wp-image-42" title="screenshot-2004-file-browser1" src="http://blog.redinnovation.com/wp-content/uploads/2008/05/screenshot-2004-file-browser1-150x150.png" alt="" width="150" height="150" /></a><a href="http://blog.redinnovation.com/wp-content/uploads/2008/05/screenshot-2004-file-browser.png"><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.redinnovation.com/2008/05/07/viivi-wagner-strip-scaper/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PyS60 application release build toolchain</title>
		<link>http://blog.redinnovation.com/2008/04/19/pys60-application-release-build-toolchain/</link>
		<comments>http://blog.redinnovation.com/2008/04/19/pys60-application-release-build-toolchain/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 23:08:35 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
		
		<category><![CDATA[pys60]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[series 60]]></category>

		<category><![CDATA[symbian]]></category>

		<category><![CDATA[build process]]></category>

		<category><![CDATA[dll]]></category>

		<category><![CDATA[extension]]></category>

		<category><![CDATA[make]]></category>

		<category><![CDATA[native]]></category>

		<category><![CDATA[pkg]]></category>

		<category><![CDATA[release]]></category>

		<category><![CDATA[sis]]></category>

		<category><![CDATA[sisx]]></category>

		<category><![CDATA[toolchain]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/2008/04/19/pys60-application-release-build-toolchain/</guid>
		<description><![CDATA[A common question for Python for Series 60 newcomers is how to build standalone Symbian applications from Python source code. We have been using Makefile based toolchain internally. I describe it in this picture, I didn&#8217;t bother to add thumbnail for the image, since it&#8217;s a 3400 pixels wide diagram.
The diagram describes building a PyS60 [...]]]></description>
			<content:encoded><![CDATA[<p>A common question for Python for Series 60 newcomers is how to build standalone Symbian applications from Python source code. We have been using Makefile based toolchain internally. I describe it in <a href="http://blog.redinnovation.com/wp-content/uploads/2008/04/pys60-tool-chain.png" title="Python for Series 60 standalone application toolchain">this picture,</a> I didn&#8217;t bother to add thumbnail for the image, since it&#8217;s a 3400 pixels wide diagram.</p>
<p>The diagram describes building a PyS60 application with some Python extensions (Symbian native C++) mixed in and bundling it all to one downloadable SIS file. The application will appear as any first class S60 application in the menu and the user does not know it&#8217;s running Python internally, besides bad installation experience (it challenges Microsoft installers with all those unnecessary yes/no questions), extra uninstaller entries and slow start-up time.</p>
<p>The biggest problems are caused by embedded SISs (SIS inside other SIS files) which are not treaded very wel by several Symbian parties.  In theory, it could be build one monolithic SIS, but you&#8217;d need to recompile PyS60 from scratch and patch UIDs inside it for your own UIDs received from symbiansigned.com. We are planning to explore SCons based build solution to address this problem, since Makefiles are a bit unflexible with tasks like PKG file and UID range generation.</p>
<p><a href="http://blog.redinnovation.com/wp-content/uploads/2008/04/example-pkg.txt" title="example-pkg.txt">Here is a PKG file example for final user distributable SIS file</a>.</p>
<p>Also, see <a href="http://code.google.com/p/uikludges">UIKludges project</a> for additional details for PKG files of Python extensions.</p>
<p>You need to have</p>
<ul>
<li>Ensymble tool</li>
<li>Series 60 SDK (contains some old GNU make)</li>
</ul>
<p>You need to master</p>
<ul>
<li>A build tool (make)</li>
<li>Symbian PKG file structure</li>
<li>Lots of different command line tools</li>
</ul>
<p>Pros</p>
<ul>
<li>It&#8217;s the best one we have for now</li>
</ul>
<p>Cons</p>
<ul>
<li>Symbian signing and certification companies don&#8217;t understand embedded SIS files (all SIS files must be signed prior embedding) and may have hard time signing SIS files containing only an extension DLL for Pyton. Symbian Signed test criteria has been built only UI application based SIS files in the mind.</li>
<li>You cannot cook your own patched PyS60 distribution without revamping some hardcoded UIDs and paths, since otherwise there are UID conflicts (EXE and DLL file UIDs are in Nokia&#8217;s protected range)</li>
<li>S60 installers askes extra confirmation for every embedded SIS file, even in the middle of the progress bar, so the user experience of installation is screwed up</li>
<li>There will extra uninstallation entry for every embedded SIS file in S60 application manager confusing the user</li>
<li><em>As you can see, most cons come from Symbian and Symbian signing limitations and have nothing to do with Python</em></li>
</ul>
<p>Ps. I would have put this thing to wiki.opensource.nokia.com, but their webmaster email address is non-functional and one cannot upload images to their Wiki.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.redinnovation.com/2008/04/19/pys60-application-release-build-toolchain/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The good, the bad and the Zope</title>
		<link>http://blog.redinnovation.com/2008/04/18/the-good-the-bad-and-the-zope/</link>
		<comments>http://blog.redinnovation.com/2008/04/18/the-good-the-bad-and-the-zope/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 10:26:57 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
		
		<category><![CDATA[python]]></category>

		<category><![CDATA[zope]]></category>

		<category><![CDATA[]]></category>

		<category><![CDATA[architecture]]></category>

		<category><![CDATA[components]]></category>

		<category><![CDATA[failure]]></category>

		<category><![CDATA[headache]]></category>

		<category><![CDATA[mindshare]]></category>

		<category><![CDATA[plug in]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/2008/04/18/the-good-the-bad-and-the-zope/</guid>
		<description><![CDATA[I want to use Zope 3 interface package to write component architecture i.e. have a plug-ins easily in Python. Zope 3 interfaces are very handy and, which cannot be conducted from the name, are available outside Zope too. From my prior experiences I know that Zope 3 interfaces package is one of the best and [...]]]></description>
			<content:encoded><![CDATA[<p>I want to use Zope 3 interface package to write component architecture i.e. have a plug-ins easily in Python. Zope 3 interfaces are very handy and, which cannot be conducted from the name, <em>are available outside Zope</em> <em>too</em>. From my prior experiences I know that Zope 3 interfaces package is one of the best and most underrated Python packages out there. It even influenced to the new design of Python 3k.</p>
<p>Well then&#8230; I haven&#8217;t used Zope 3 interfaces standalone before, so the first thing what I do is writing &#8220;zope 3 interfaces&#8221; into my Google search this.</p>
<p><a href="http://wiki.zope.org/Interfaces/FrontPage">This page comes up</a>.</p>
<p>It&#8217;s horrible - the very reason I write this quick blog entry. Some notes below  (I have written things from the point of external visitor - I have hands deep in Zope myself, so you don&#8217;t need to clarify these things for me or teach anything)</p>
<ul>
<li>The information is tangled mess: please use subtitles and images</li>
<li>You could mention that the package can be used outside Zope</li>
<li>You could mention tat the package is a generic Python package</li>
<li>The list of CamelCaseWordsWhichGoesOnAndOnUnexplained made me puke. Please use proper English and explain the meaning of the links.</li>
<li>It has a comment box: I tried to comment the page but I will get permission error. Please do not show the comment box if the commenting is not actually possbile.</li>
<li>Then I tried to register to Zope.org to comment or fix the basic things on the page. You have a join link in zope.org, but there is no registration form. Manual email conversation seem to be prerequisite for the registration. Is Zope a secret society or something&#8230;? The contribution barrier just rise too high.</li>
<li>In this point, I give up. Even if you had  the best interface package out there,  I don&#8217;t care anymore. Looks like getting involved to fixing thing takes too much of my time. You had your 10 minutes of time to impress me and you failed. Not only that, but I got so frustrated that I want to learn smoking, fast.</li>
</ul>
<p>In the post <a href="http://faassen.n--tree.net/blog/view/weblog/2008/04/05/0">&#8220;No, you are not smart enough for Zope</a>&#8221; Martjin Faassen highlights some problems of Zope community. <span class="entryText"> &#8220;It&#8217;s <em>hard</em> to get good content written&#8221; Martjin claims. I disagree. Whoever created the page originally could <em>have</em> <em>thought </em>what people coming to the page want. They don&#8217;t want to decrypt the brain core dump of  hardcore Zope developer. They want to know <em>what is this thing, how this thing is beneficial for them</em>, <em>how do I get started with it</em> and <em>how do I use it</em>.  </span></p>
<p><span class="entryText">You all know how Internet works. You all have visit on web pages. You all are customers for the same thing you also produce. So writing a basic web page is not something you couldn&#8217;t do.</span></p>
<p>Hints:</p>
<ul>
<li> apt-get install python-zopeinterface</li>
<li><a href="http://svn.zope.org/zope.interface/trunk/src/zope/interface/README.txt?view=markup">README.TXT</a></li>
</ul>
<p>Pardon me the tone of this post. Zope is the 23th best thing out there, but the Zope community has stagnated badly in some aspects. Some things were acceptable ten years ago when web was still young and Python developers hardcore, but <a href="http://www.google.com/trends?q=zope">if you don&#8217;t keep with the pace you lose all the mindshare</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.redinnovation.com/2008/04/18/the-good-the-bad-and-the-zope/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Verifying Javascript files with JSLint from Eclipse IDE</title>
		<link>http://blog.redinnovation.com/2008/03/27/verifying-javascript-files-with-jslint-from-eclipse-ide/</link>
		<comments>http://blog.redinnovation.com/2008/03/27/verifying-javascript-files-with-jslint-from-eclipse-ide/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 13:10:08 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[debugging]]></category>

		<category><![CDATA[dojo]]></category>

		<category><![CDATA[eclipse]]></category>

		<category><![CDATA[ext js]]></category>

		<category><![CDATA[extjs]]></category>

		<category><![CDATA[jseclipse]]></category>

		<category><![CDATA[jslint]]></category>

		<category><![CDATA[rhino]]></category>

		<category><![CDATA[verify]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/2008/03/27/verifying-javascript-files-with-jslint-from-eclipse-ide/</guid>
		<description><![CDATA[With Web 2.0, Javascript has gained a great foothold in the web development. Javascript, which was originally indented to be few lines of interactivity here and there, is now used for full-blown UI frameworks like Ext JS and Dojo. Because its toy background, Javascript is not the easiest language to debug. Also, the lovely phenomenon [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.redinnovation.com/wp-content/themes/redinnovation/images/naama4.jpg" align="left" height="154" hspace="10" vspace="10" width="128" />With Web 2.0, Javascript has gained a great foothold in the web development. Javascript, which was originally indented to be few lines of interactivity here and there, is now used for full-blown UI frameworks like <a href="http://www.extjs.com">Ext JS</a> and <a href="http://www.google.com/url?sa=t&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fdojotoolkit.org%2F&amp;ei=QYfrR52DBp_8wwHn9MEV&amp;usg=AFQjCNGA7YR8rGVmo1u_5-t7HJyhmL1beA&amp;sig2=PqVEAHMMcKrl91DUl8NGxA">Dojo</a>. Because its toy background, Javascript is not the easiest language to debug. Also, the lovely phenomenon known as browser wars has ensured that professional Javascript  development is PITA due to browser incompatibilities - It seconds the Symbian C++ embedded programming if you know what I mean.</p>
<p>Javascript is executed run-time. Thus, any errors cannot be cached until the code is run. <a href="http://www.jslint.com/">JSLint</a> is a verifier tool which checks Javascript syntax  offline. Of course, it cannot detect application logic errors, but it makes sure that you don&#8217;t have cross-browser compability problems in your Javascript syntax. Maybe the most famous of these problems is  the extra comma before the list termination which is ok for Firefox, but kills the page on Internet Explorer.</p>
<p>Some argue that <a href="http://dean.edwards.name/weblog/2006/06/jslint/">this does not really catch bugs</a> and instead a comprehensive unit-test suite should be used. This might be a requirement for a platform level Javascript library code, but it is often an overkill for your little site with some flashy dialog windows.</p>
<p><strong>Installing JSLint</strong></p>
<p>JSLint itself is written in Javascript. So you need to offline Javascript interpreter to run it. On Linux there exists Rhino. On Ubuntu, <a href="https://bugs.launchpad.net/ubuntu/+source/rhino/+bug/93885">Rhino package is broken</a>. and you need to download the orignal Rhino JAR from <a href="http://developer.mozilla.org/en/docs/Rhino_downloads_archive">here</a> and copy it to <em>/usr/share/java</em>.</p>
<pre>sudo apt-get install rhino # Note https://bugs.launchpad.net/ubuntu/+source/rhino/+bug/93885</pre>
<p>Then  get JSLint offline version from <a href="http://www.jslint.com/rhino/jslint.js">here</a>.</p>
<p><strong>Running JSLint straight from the Eclipse</strong></p>
<p>We use <a href="http://www.interaktonline.com/Products/Eclipse/JSEclipse/Overview/">JSEclipse</a> plug-in in Eclipse for Javascript development. Thus, it is convenient to to execute JSLint directly from the Eclipse IDE.</p>
<p>Drag and drop jslint.js to your project/scripts folder in Eclipse.</p>
<p>Create a new External tool like in the example below.</p>
<p><a href="http://blog.redinnovation.com/wp-content/uploads/2008/03/screenshot-external-tools.png" title="screenshot-external-tools.png"><img src="http://blog.redinnovation.com/wp-content/uploads/2008/03/screenshot-external-tools.thumbnail.png" alt="screenshot-external-tools.png" /></a></p>
<p>Then you can run it by just clicking &#8220;run external tool&#8221; icon. Output comes to the console window.</p>
<p><a href="http://blog.redinnovation.com/wp-content/uploads/2008/03/screenshot-pydev-nurse-source-server-media-js-ui-mapjs-eclipse-sdk.png" title="screenshot-pydev-nurse-source-server-media-js-ui-mapjs-eclipse-sdk.png"><img src="http://blog.redinnovation.com/wp-content/uploads/2008/03/screenshot-pydev-nurse-source-server-media-js-ui-mapjs-eclipse-sdk.thumbnail.png" alt="screenshot-pydev-nurse-source-server-media-js-ui-mapjs-eclipse-sdk.png" /></a></p>
<p><strong>Checking all Javascript files during unit test  </strong></p>
<p><a href="http://blog.redinnovation.com/wp-content/uploads/2008/03/verify_javascript.bash" title="verify_javascript.bash">verify_javascript.bash</a> can be executed from shell and it checks all JS files in your project. This is a nice feature to integrate to your unit test cycle.</p>
<p>Example:</p>
<pre>
$ bash scripts/verify_javascript.bash source/server/media/jssource/server/media/js/jquery.js

Lint at line 11 character 30: Expected '{' and instead saw 'var'.

...</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.redinnovation.com/2008/03/27/verifying-javascript-files-with-jslint-from-eclipse-ide/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flex 3 SQLite and the mystery of &#8220;text value to numeric value&#8221;</title>
		<link>http://blog.redinnovation.com/2008/03/14/a-short-story-about-why-to-rtfm/</link>
		<comments>http://blog.redinnovation.com/2008/03/14/a-short-story-about-why-to-rtfm/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 19:13:29 +0000</pubDate>
		<dc:creator>saarni</dc:creator>
		
		<category><![CDATA[Adobe AIR]]></category>

		<category><![CDATA[Flex 3]]></category>

		<category><![CDATA[sqlite]]></category>

		<category><![CDATA[rtfm]]></category>

		<category><![CDATA[timestamp]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/2008/03/14/a-short-story-about-why-to-rtfm/</guid>
		<description><![CDATA[Learning new development environments and languages can be quite fun, but sometimes it turns out just plain frustrating. Especially so if you are trying to learn something that is still in its beta stage. This time it was Adobe AIR and Flex 3.
The program in question required storing date and time values in an sqlite3 [...]]]></description>
			<content:encoded><![CDATA[<p>Learning new development environments and languages can be quite fun, but sometimes it turns out just plain frustrating. Especially so if you are trying to learn something that is still in its beta stage. This time it was Adobe AIR and Flex 3.</p>
<p>The program in question required storing date and time values in an sqlite3 database. Now, as the title of this entry says, I should&#8217;ve just read the AIR sqlite handling manual 1 more time (or 2-10 more times) and I could&#8217;ve learnt that AIR SQL handling accepts &#8220;Date&#8221; as column type and handles inserting and getting Date objects from the database transparently. I did not notice this while studying and used &#8220;TIMESTAMP&#8221; as column type instead. This is where things went wrong&#8230; so wrong&#8230;</p>
<p>Using &#8220;TIMESTAMP&#8221; column type and inserting datetime strings worked flawlessly in the betas along with using sqlite date functions. But AIR 1.0 release came and suddenly my application started producing the following SQL errors everywhere:</p>
<p><code>SQLError: 'Error #3115: SQL Error.', details:'could not convert text value to numeric value.', operation:'execute'</code></p>
<p>Naturally for a few days I went through my SQL code and tables trying different things on columns that had types like &#8220;INTEGER&#8221;, &#8220;REAL&#8221;, &#8220;NUMERIC&#8221; and so on. After trying and trying I finally decided to read the AIR documentation again. The essential part turned out to be how AIR handles the column affinities in the release version: everything not recognized by AIR is given &#8220;NUMERIC&#8221; column affinity. This and the fact that AIR is now stricter about types is what changed between the betas and release version and broke the columns with &#8220;TIMESTAMP&#8221; as type since I was trying to insert text.</p>
<p>So, again, I should&#8217;ve just rtfm&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.redinnovation.com/2008/03/14/a-short-story-about-why-to-rtfm/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Symbian digging its own grave with symbiansigned.com</title>
		<link>http://blog.redinnovation.com/2008/03/14/symbian-digging-its-own-grave-with-symbiansignedcom/</link>
		<comments>http://blog.redinnovation.com/2008/03/14/symbian-digging-its-own-grave-with-symbiansignedcom/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 14:41:23 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
		
		<category><![CDATA[signing]]></category>

		<category><![CDATA[symbian]]></category>

		<category><![CDATA[certificate]]></category>

		<category><![CDATA[developer]]></category>

		<category><![CDATA[feedback]]></category>

		<category><![CDATA[series 60]]></category>

		<category><![CDATA[symbiansiged]]></category>

		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/2008/03/14/symbian-digging-its-own-grave-with-symbiansignedcom/</guid>
		<description><![CDATA[Edit: Made correction to iPhone SDK price/added self-signed option
I have been recently involved in Symbian development. Unfortunately, I could say. Symbian has made the life of Symbian developers headacheful. The main problem is that the application signing is made unnecessary cumbersome. Getting a required developer certificate to just to run your one liner test code [...]]]></description>
			<content:encoded><![CDATA[<p>Edit: Made correction to iPhone SDK price/added self-signed option</p>
<p>I have been recently involved in Symbian development. Unfortunately, I could say. Symbian has made the life of Symbian developers headacheful. The main problem is that the application signing is made unnecessary cumbersome. Getting a required developer certificate to just to run your one liner test code is a long road paved with curses, stress and ponder how a world class company can screw up things so badly.</p>
<p>I write this post to vent out the frustration. Hopefully someone picks up the feedback presented here. Personally, I don&#8217;t care anymore really. After explaining to the customer once &#8220;I am afraid that we cannot have the demo in this meeting, since we were unable to get the developer certificates in time. It was nice you did summon all of your executes, though.&#8221;  my sympathy towards Symbian has fallen to zero.</p>
<p>In the long run, I believe, this will hurt Symbian when developers leave the platform. When this happens Symbian will miss 1) developer base 2) the wow value of all new cool things when hackers move to happier platforms - after all you don&#8217;t want to work with things causing a headache even if you are paid generously. Professional Symbian capable developers are already rare and scaring away the potential candidates (students, open source developers, freeware developers) won&#8217;t really help the matter. Of course, for us, who are already in the business, it&#8217;s good since we can raise our hourly fee and die as rich dinosaurs (remember COBOL).</p>
<p>Looks like the root problem is the cocky attitude: &#8220;We are the biggest mobile operating system in the world. You are not our customer, the biggest mobile phone brands are. Thus, you are an insignicant fly and we don&#8217;t need to listen to you. Please go away.&#8221;  The big boys tell that this very same reason lead to Motorola&#8217;s fall from the number one mobile phone vendor position - so let&#8217;s see if the history is repeating itself.</p>
<p>The problems of Symbian development process, especially signing, are well known. <a href="http://developer.symbian.com/forum/category.jspa?categoryID=2">Symbian Signed forum category has 120 000 views</a>. Symbian signed support requests <a href="http://developer.symbian.com/forum/category.jspa?categoryID=2">has 57 000 views and 2000 messages</a>, since November 2007. Over a thousand support requests in four months. Symbian has money. It could fix the problem if it has will. If there is will in the organization and the work just does not progress, the corporate world has a simple solution: fire the management and hire capable responsible persons.</p>
<p>I won&#8217;t go the details of the problems in this post. I have prepared a post containing over 50 bulletins with detailed steps to get the developer certification process done and it lists every little mistake in Symbian Signed process. Unsurprisingly, the post mentions fuck and hell over twenty times, so I am reluctant to post it on our company site. So I sketched a manager comprehensible overview of the state of the process in this post. To justify my criticism, I compare Symbian to Apple iPhone and make some suggestion how to fix things.</p>
<h1>Certificate costs</h1>
<p><strong>Symbian</strong>: 200$/1.5 years (you need a publisher id to get a developer certificate) + 20$ per signing round</p>
<p>Update: <a href="http://www.symbian.com/developer/techlib/v9.1docs/doc_source/N10356/Installing/HowToMakekeys.guide.html">You can still make self-signing certificates</a> yourself with limited capabilities (no GPS), but symbiansigned.com doesn&#8217;t bother to mention it.</p>
<p><strong>Apple</strong>: 99$/year (for testing and distribution applications)</p>
<p>Suggestion: Make the developer certificate free. It used to be free, but based <a href="http://developer.symbian.com/forum/ann.jspa?annID=36">on this post</a>, Symbian signed claims that they do not have enough CPU power, because of all kind of nasties are knocking their server. Come on! it&#8217;s Internet. You are hosted by Cidercone and by knowing how much they charge for the hosting I believe you can get every possible server power in the world to generate your keys.</p>
<p>This development start up cost automatically excludes third world people, freeware makers and students i.e. the future Symbian professionals. It&#8217;s hard to maintain a platform if there is not enough skilled people to work with it. There won&#8217;t be meat into Nokia&#8217;s and Sony-Ericsson&#8217;s innovation machines.</p>
<h1>Development start lead time</h1>
<p>How long it takes to get &#8220;Hello World&#8221; code to the phone.</p>
<p><strong>Symbian</strong>: 8 workdays</p>
<p><strong>Apple</strong>: 6 hours</p>
<p>Complete Guide to Symbian Signed guide (manual) is 20 pages PDF. How often you need a user manual to use a web site? Even with this page amount, the manual lacks crucial pieces of information which you need to hunt and ask help from the Symbian Signed support forums. I had to make 3 support request for Symbian Signed and 1 for TrustCenter.</p>
<h1>Set-up process</h1>
<p><strong>Symbian</strong>: Create 3 user accounts (symbiansigned.com, developers.symbian.com, TrustCenter). Fax your passport and some signed papers to TrustCenter Germany. Wait when your request is manually processed. Ask TrustCenter what I do with the link they send me (hint: the only working web browser for their site is the very same browser you orignally submitted your application from). Convert TrustCenter key to Symbian specific format using obscure BAT tool. Use half-baked Windows EXE to generate files. Ask at the support forums permission <strong>to be allowed </strong>to create the Publisher id.</p>
<p><strong>Apple:  </strong>Download SDK. Click &#8220;I Agree.&#8221;</p>
<p>Symbiansigned management team must be either incomplete or inexistent, or they just hate their users. Looks like no one didn&#8217;t bother model or test this process, since the flaws are so apparent. Why do we need three user accounts? Why do we need a user account at all, isn&#8217;t my credit card payment enough? Why there can&#8217;t be a single web page on symbiansigned.com where I could do these all things without? Also, Symbian could do these things without third parties (TrustCenter) who are badly integrated to the process.</p>
<h1>Web site and information reachability</h1>
<p><strong>Symbian</strong>: Two sites with different user accounts. Information is spread around and hidden behind various for registred users only pages. Often Symbian PDFs (yes they seem to prefer zipped PDFs) and web pages cross-link to other sites and these links are broken. Their internal site search engine does not give meaningful results. Google cannot search pages, since they are hidden behind the registration. Web forms don&#8217;t work. Navigation paths are unclear and you often need to guess where a certain piece of information could be.</p>
<p><strong>Apple</strong>: One site - and it just works.</p>
<p><a href="http://developer.symbian.com/forum/thread.jspa?messageID=71782ᡦ">Why Symbian hides a crucial BAT tool</a> in the page labyrinth of developers.symbian.com and behind login? Does the 100 lines of BAT code contains a very hidden trade secret? I doubt. (I also doubt that a BAT tool is a good way to solve a problem which could be fixed with a web form or Javascript, but that&#8217;s another matter.)</p>
<p>I think this is the part of the attidude problem. SymbianSigned.com mission is not to &#8220;secure&#8221; the development and control the developers of the platform. It&#8217;s mission should be easily enable developers to start development and release their software for Symbian. The meaning of &#8220;easily&#8221; includes that the web site is working and up to the standards. Please hire a usability expert (we are here) and get it fixed. This problem is <em>not </em>solvable by writing yet-another user manual PDF.</p>
<h1>Giving feedback</h1>
<p><strong>Symbian:</strong> Support like goes to the Symbian developer forum. A bulleting board with unorganized, angry, posts. They don&#8217;t give a feedback form to report the problems on Symbian Signed.</p>
<p><strong>Apple:</strong> &#8220;There are three great ways to get answers to your questions about ADC membership, products, and services: visit our <a href="http://developer.apple.com/faq/">Frequently Asked Questions</a> web pages, submit your questions or feedback using the form below, or <a href="http://developer.apple.com/contact/phone.html">call us</a> to speak directly to a worldwide support agent. We look forward to assisting you.&#8221;</p>
<p>I&#8217;d help symbiansigned.com to get its site better if I could. When there is a broken link, I can hit feedback and ask them to fix it. But looks like they want to be ignorant about the matter - if I report a problem on their forum I bet no one will ever fix it. There won&#8217;t be even &#8220;thank you.&#8221; Probably no one ever reads my post. On the other hand, when having such non-functional service, this feedback channel would be flooded in overnight.</p>
<h1>Conclusion</h1>
<p>Symbian has unforgiveable screwed up with its signing process and doesn&#8217;t seem to get the feedback from the developers who suffer from it. <a href="http://www.youtube.com/watch?v=KMU0tzLwhbE">Steve Ballmer&#8217;s famous quote &#8220;developers, developers, developers&#8221;</a> refer to what&#8217;s the important factor making the platform succesfully in long term.  This is especially crude when you know that things <em>used to be </em>good.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.redinnovation.com/2008/03/14/symbian-digging-its-own-grave-with-symbiansignedcom/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SDK released - Python in iPhone?</title>
		<link>http://blog.redinnovation.com/2008/03/07/sdk-released-python-in-iphone/</link>
		<comments>http://blog.redinnovation.com/2008/03/07/sdk-released-python-in-iphone/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 15:36:11 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
		
		<category><![CDATA[iphone]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[language]]></category>

		<category><![CDATA[run-time]]></category>

		<category><![CDATA[sdk]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/2008/03/07/sdk-released-python-in-iphone/</guid>
		<description><![CDATA[I just read waffle&#8217;s blog entry about iPhone SDK release. Looks like Objective C is the only supported language by default (I am just downloading SDK).The comments speculated that embedding Python is not possible due to size constraints. Bollocks I say =) Python for Series 60 phones is 500 kb download without trimming. It&#8217;s less [...]]]></description>
			<content:encoded><![CDATA[<p>I just read <a href="http://waffle.wootest.net/2008/02/24/bold-statements-iphone-sdk/">waffle&#8217;s blog entry about iPhone SDK release</a>. Looks like Objective C is the only supported language by default (I am just downloading SDK).The comments speculated that embedding Python is not possible due to size constraints. Bollocks I say =) Python for Series 60 phones is 500 kb download without trimming. It&#8217;s less than the size of HTML page you are viewing now - RAM footprint is even smaller) If Series 60 phones, which have much more <span lang="en">modest</span> hardware specifications, can run Python it shouldn&#8217;t be a problem for iPhones either.</p>
<p>Why Apple didn&#8217;t add additional language support by default? Well they seem to have their hands full to get SDK out at all (delays) so we shouldn&#8217;t expect to have perfect set in 1.0 release.</p>
<p>Now, who wants start a porting project with me? <img src='http://blog.redinnovation.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.redinnovation.com/2008/03/07/sdk-released-python-in-iphone/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
