Mercurial > salut
changeset 2:77b77f48c975
don't expect queries to specify all the fields
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 23 Jul 2015 21:05:51 +0200 |
parents | 92549e4336a6 |
children | 593345584d21 |
files | salut.py |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/salut.py Mon Mar 30 10:30:54 2015 +0200 +++ b/salut.py Thu Jul 23 21:05:51 2015 +0200 @@ -94,13 +94,18 @@ try: query_elt = request.elements(NS_SEARCH, 'query').next() form_elt = query_elt.elements(data_form.NS_X_DATA, 'x').next() + except StopIteration: + raise ValueError # TODO: proper error handling + else: parsed_form = data_form.Form.fromElement(form_elt) for col in ('jid', 'description'): - value = parsed_form[col].strip() - if value: - args[col] = value - except (StopIteration, KeyError): - raise ValueError # TODO: proper error handling + try: + value = parsed_form[col].strip() + except KeyError: + pass + else: + if value: + args[col] = value if args: query.append("WHERE")