IntegrityErrors in

Issue #5 resolved
Jakub Wiśniowski
created an issue

There is a common pattern in to catch IntegrityError exceptions. It is ok with sqlite but not with Postgres - there IntegrityError breaks whole transaction. So my proposal is to replace code like (from register_permission): {{{


try: p = Permission.objects.create(name=name, codename=codename) p.content_types = ctypes except IntegrityError: return False }}}




p, created = Permission.objects.get_or_create(name=name, codename=codename)
p.content_types = ctypes


It's not perfect but it's simple and works well with multiple calls to register_permission (group, role) functions.

Comments (2)

  1. Log in to comment