comparison sat_pubsub/pgsql_storage.py @ 332:31cbd8b9fa7f

pgsql: node creation now return error.NodeExists in case of unique violation, and InvalidConfigurationOption else
author Goffi <goffi@goffi.org>
date Mon, 03 Apr 2017 00:24:34 +0200
parents e93a9fd329d9
children 57a3051ee435
comparison
equal deleted inserted replaced
331:e93a9fd329d9 332:31cbd8b9fa7f
223 config[const.OPT_ACCESS_MODEL], 223 config[const.OPT_ACCESS_MODEL],
224 config[const.OPT_PUBLISH_MODEL], 224 config[const.OPT_PUBLISH_MODEL],
225 recipient.userhost() if pep else None 225 recipient.userhost() if pep else None
226 ) 226 )
227 ) 227 )
228 except cursor._pool.dbapi.IntegrityError: 228 except cursor._pool.dbapi.IntegrityError as e:
229 raise error.NodeExists() 229 if e.pgcode == "23505":
230 # unique_violation
231 raise error.NodeExists()
232 else:
233 raise error.InvalidConfigurationOption()
230 234
231 cursor.execute(*withPEP("""SELECT node_id FROM nodes WHERE node=%s""", 235 cursor.execute(*withPEP("""SELECT node_id FROM nodes WHERE node=%s""",
232 (nodeIdentifier,), pep, recipient)); 236 (nodeIdentifier,), pep, recipient));
233 node_id = cursor.fetchone()[0] 237 node_id = cursor.fetchone()[0]
234 238