Skip to main content

Posts

Pycon Apac 2011

Pycon APAC 2011 in Singapore finally end this evening and this is some quick recaps on the event for the past few days. Day 1 (Tutorial) This is tutorial day only. The conference actually started on the second day. I took the Python 102 class. Initially I want to attend Practical Django project by Jacob Kaplan Moss but since my boss already took that class and we didn't want to attend the same class I picked Python 102. I thought this could be somewhat 'formal' Python class for me. Turn out it really meant for beginner. I don't know what they touched in 101 but it look to me just a repetition of what in 101 class. But I still manage to know few things that I'm not aware off. It some kind of basic but I never learn Python in formal, I just picked up the specific part of the language that can solve problem at my hand. Use negative (-) sign to apply string formatting backward. Use double, triple and so on colon in list slicing as step. Really nice feature. Enumerate to...

Planning

There are so much things that I want to write down but can't find out a time to do it. Lately my time management seem to be the worst ever. So I'll try to jot down first what in my head and hopefully I can write about it soon. Understanding Django Content Type framework - I've been working on application that require me to use Django's Content Type framework (at least I decided to use contenttype to accomplish the task). Along the way I started to understand how Django implemented it. Content type concept not really unfamiliar to me since Drupal also using the concept for their Information Archictecture (IA). Django Content Type however seem much more flexible (compared to pre Drupal 7) and simpler to understand (compared to Drupal 7 similar concept). Using Django's haystack app for search in your website/application - I decided to use haystack to provide search in another application I've developing and quite excited to see how simpler and fast I can get sea...

Django transaction.commit_manually mask uncaught exception

Update 2012-08-27 I've created a wrapper to the decorator that catch, rollback transaction and reraise the exception:- http://tech.marimore.co.jp/2012/08/django-transactioncommit_manually-wrapper.html This has happened number of times for me. There's a 3 year old ticket on this actually but since I want to be quick and no time yet to look into the ticket, the solution is to wrap all my function with a decorator that can catch the exception and exit immediately. I'm doing this in a batch script so what I want is either the script succeed or fail immediately, showing the error. YMMV.

Tree structures in relational database

Into Tree again. I'm a fan of Materialized Path but a bit worried with the limitation to the number of branches. It's ok for something like gov ministry where most of the time the number of agency and department already expected and doesn't change/grow much but with MLM kind of system, we should expect it to expand as wide and depth as possible. Think better start with adjacency model first (and maybe combined with mat path for easy retrieval). From there it's still possible to move to other models. http://www.sqlteam.com/article/more-trees-hierarchies-in-sql http://stackoverflow.com/questions/2797720/sorting-tree-with-a-materialized-path http://www.ibstaff.net/fmartinez/?p=18

Better pager for psql/mysql client

Very nice tips I found today - http://merlinmoncure.blogspot.com/2007/10/better-psql-with-less.html If you used psql or mysql client on the console a lot, it always a problem browsing through result set that much wider that your console width. export PAGER=less export LESS="-iMSx4 -FX" Then just make sure your psql/mysql use the correct pager. For mysql, \P would set pager to "less".

There's more than Cpanel in this world

My brother bought simple local e-commerce application. PHP application actually. It's quite simple, the typical add to cart stuff with extra features to track affiliation. Nothing that Drupal/Ubercart can't do. But I can see a reason for people to buy that. Buying off the shelf software is cheap (provided it work out of the box) compared to developer's time to setup an open source equivalent. I'm hosting all my brother's website so for this one I just created another user inside my Webfaction account, point the php/symlink application to the DocumentRoot inside that user's home directory, create mysql database and all set to go. But there's one problem. Clicking on certain link that supposed to open a popup just load up the main page instead of the desired page. Since it look like a routing problem, I take look at .htaccess file. There seem to be few rules that route incoming url to the php file. Looking at source code, it turned me off a lot. IonCube encode...

Django: empty clause in for loop

One thing I like about Jinja is the else clause in the for ... in loop syntax. It handy when you want to display something like "Your cart is empty ..." when looping through a list of items, if the items is empty. It not obvious in the documentation but after searching around, I found out that Django also had the same functionality now in changeset 9530 . That's about 2 years ago, so much things I miss in Django world. Django use the keyword "empty" rather than "else" as in Jinja. {% for item in items %} ... {% empty %} Your cart is empty {% endfor %}