Patrick's code doesn't solve the concurrency problem, through no fault of his own, though. If the lock (select for update) is executed at the application level it will, but it doesn't help within PL/pgSQL. If another process has already entered the trigger its "select for update" won't block.
Ain't it lovely? I'm sure I've posted details to the forums before.
Now if PG locking worked right (like Oracle!) the code would be correct.