As you may, or may not know, for the last week, i’ve being trying to develop a new version for The Herd – the Ubiquity command aggregator.

I took this decision because the actual version does not work at all – mainly because we’re having too much problems with CouchDB (not that it’s a bad database, but our installation is behaving quite strangely).

The Herd today, is developed on top of Django – and after talking to Atul about this, i decided to drop Django entirely and use web.py.

My main reasons are:

1. Django is a full stack framework that makes you use their templates+their apis+lot’s of things – and for Herd, we wanted to do something like a REST-server with a html+css+js frontend
2. Django doesn’t have a good integration with schema-less databases (we *need* it for herd)

It uses web.py, MongoDB (it’s a great schema-less database) and simplejson for the server and plain html+css+jquery for the front-end (that i really need to improve).

It’s been 9 days now, and the new version is quite usable – it already fetches/parsers the feeds.
You can login (using openid) and comment on feeds (voting is almost complete too).

I hope i can “finish” it by the end of the week so i can really focus on the ui. (i will need some help on that).

The bold part is the main thing — is the hibernate’s 2nd level cache implementation. I recommend you to put the show_sql to true, just to see when a query hits the database.

Then create a file called hibernate-cache-config.xml (ok, the actual name doesn’t really matter…) and put the following content on it: http://pastebin.com/f7c883504
This file contains the configuration on how the cache should be created, replicated and etc.

Now, put
static mapping = {
cache true
}

on the domain classes you want to cache. (this is important — and i didn’t know that, but thanks to Les Hazlewood’s explanation on this thread i know why i need it)

Now, let’s test it!

Fire-up a grails console instance with the following command:
grails -Dtangosol.coherence.cacheconfig=./hibernate-cache-config.xml -Dtangosol.coherence.hibernate.cacheconfig=./hibernate-cache-config.xml console

With this command you set two system variables (coherence uses them) that point to the file we created later.

After typing enter (duh!) you will see a lot of messages about coherence (just like the ones you saw when starting the console) (note: i recommend you not to have any other instance of coherence running when doing these tests). When the coherence finally started, save some instances of your domain class(ess) — i.e.:

This week i have a task: explore JHeadstart — Easy — specially if you follow their (uncommented) tutorial. But, when you start to build your own app, things start to get a little confusing (and, difficult) — specially because, by default, the framework creates screens with ids (the user can input whichever id they want) and this is not the right thing on a real-world-app. Ok, but if the user is not going to input the id, we have to create an auto-increment on the column.

Easy. Just put the auto_increment on the column…. No, not.
On Oracle DBs, different of MySQL, you cannot set an column to auto_increment, and it’s not easy to discover how to do it (if you don’t have an oracle dba in the house).

So, god google showed me a link telling me how to do it. If you don’t want to click on the link, i’ll show it for you here.

First, you need to create an sequence — the sequence is the ‘auto-increment-thing’, the one that’ll give to you the numbers.

create sequence funcs_id_seq
start with 1
increment by 1
nomaxvalue;

Then, you will have to create a trigger, that’ll be triggered when you insert an new row into the table:

create trigger func_id_trigger
before insert on functionaries
for each row
begin
select funcs_id_seq.nextval into :new.id from dual;
end;
/

Then, just to an normal insert into your table (w/o the id, of course) and the id will be setted!

Yesterday i finished my script for command completion on grails. It’s quite complete right now (not perfect, but almost complete).
I thought it would be more difficult to do it, but thanks to tutorials (here and here) and the other script for completion, it was quite easy.

I really love python. It’s a great language (fyi it’s one of the languages that google uses — they are java, python, c and c++) and has a powerful console.
But, it misses an great point: autocomplete. (A think that ruby’s console has)

So, searching on the internet i found this site that show how to do it:

First, create a new environment variable called PYTHONSTARTUP pointing to a file “$HOME/.pystartup” — you can do that using the command export PYTHONSTARTUP=”$HOME/.pystartup. (You can add the command to your .bashrc, so you don’t need to type everytime you startup a console)