diff --git a/VERSION b/VERSION index 49ea5a72..eb48a8e9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 1.99.7 (2012-03-26 11:10:04) dev +Version 1.99.7 (2012-03-26 11:13:57) dev diff --git a/gluon/contrib/populate.py b/gluon/contrib/populate.py index c1494dfd..81742d10 100644 --- a/gluon/contrib/populate.py +++ b/gluon/contrib/populate.py @@ -107,11 +107,21 @@ def populate(table, n, default=True, compute=False): for i in range(0, random.randint(0,len(options)-1)/2): vals.append(options[random.randint(0,len(options)-1)][0]) record[fieldname] = vals - elif field.type in ['integer','double'] or str(field.type).startswith('decimal'): + elif field.type =='integer': try: record[fieldname] = random.randint(field.requires.minimum,field.requires.maximum-1) except: record[fieldname] = random.randint(0,1000) + elif field.type == 'double' or str(field.type).startswith('decimal'): + if hasattr(field.requires,'minimum'): + rand=random.random() + if str(field.type).startswith('decimal'): + import decimal + rand=decimal.Decimal(rand) + record[fieldname] = field.requires.minimum+ \ + rand*(field.requires.maximum-field.requires.minimum) + else: + record[fieldname] = random.random()*1000 elif field.type[:10] == 'reference ': tablename = field.type[10:] if not tablename in ids: