# HG changeset patch # User Denis Laxalde # Date 1512037258 -3600 # Node ID 8eb15566142f5fa31f861edc62bd4bdf619d6bf9 # Parent 19aae64c401014f8c55ee00ceeda6548210851bb [server] Use dict.setdefault() instead of if/else in repo.glob_add_relations() diff -r 19aae64c4010 -r 8eb15566142f cubicweb/server/repository.py --- a/cubicweb/server/repository.py Fri Nov 03 15:26:32 2017 +0100 +++ b/cubicweb/server/repository.py Thu Nov 30 11:20:58 2017 +0100 @@ -923,10 +923,7 @@ for subjeid, objeid in eids_subj_obj: print('ADD relation', subjeid, rtype, objeid) for subjeid, objeid in eids_subj_obj: - if rtype in relations_by_rtype: - relations_by_rtype[rtype].append((subjeid, objeid)) - else: - relations_by_rtype[rtype] = [(subjeid, objeid)] + relations_by_rtype.setdefault(rtype, []).append((subjeid, objeid)) if not activintegrity: continue # take care to relation of cardinality '?1', as all eids will