From 10af0102f49c48da5d908f9c68b26bf214f52411 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 14 Jan 2013 09:42:59 -0600 Subject: [PATCH] fixed issue 1273, default int as_dict, thanks Alan --- VERSION | 2 +- gluon/dal.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0833870b..83c8712d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.1-alpha.2+timestamp.2013.01.14.09.18.01 +Version 2.4.1-alpha.2+timestamp.2013.01.14.09.41.53 diff --git a/gluon/dal.py b/gluon/dal.py index 8e58674c..b754468f 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -9577,6 +9577,22 @@ class Rows(object): :param storage_to_dict: when True returns a dict, otherwise a list(default True) :param datetime_to_str: convert datetime fields as strings (default True) """ + + # test for multiple rows + multi = False + f = self.first() + if f: + multi = any([isinstance(v, f.__class__) for v in f.values()]) + if (not "." in key) and multi: + # No key provided, default to int indices + def new_key(): + i = 0 + while True: + yield i + i += 1 + key_generator = new_key() + key = lambda r: key_generator.next() + rows = self.as_list(compact, storage_to_dict, datetime_to_str, custom_types) if isinstance(key,str) and key.count('.')==1: (table, field) = key.split('.')