reorganize helper functions

Signed-off-by: Jan Dvořák <mordae@anilinux.org>
propagate patch preprocessing errors

Signed-off-by: Jan Dvořák <mordae@anilinux.org>
remove unused function

Signed-off-by: Jan Dvořák <mordae@anilinux.org>
make preprocess code a bit more readable

Signed-off-by: Jan Dvořák <mordae@anilinux.org>
make preprocessing database-aware

Signed-off-by: Jan Dvořák <mordae@anilinux.org>
implemented x-merge patch operation

The operation itself follows semantics of JSON Merge Patch Draft.

Signed-off-by: Jan Dvořák <mordae@anilinux.org>
fix sqlalchemy exception handling

Signed-off-by: Jan Dvořák <mordae@anilinux.org>