From 1356e5b73f3910b05bc3b8fa702aa356abf816dd Mon Sep 17 00:00:00 2001 From: Massimo Di Pierro Date: Fri, 20 Jan 2012 11:23:15 -0600 Subject: [PATCH] populate can now deal with computed fields, thanks ttmost --- VERSION | 2 +- gluon/contrib/populate.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index f2ee5998..34d96c41 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 1.99.4 (2012-01-20 11:19:18) stable +Version 1.99.4 (2012-01-20 11:23:12) stable diff --git a/gluon/contrib/populate.py b/gluon/contrib/populate.py index ade6e0f8..c1494dfd 100644 --- a/gluon/contrib/populate.py +++ b/gluon/contrib/populate.py @@ -55,7 +55,7 @@ def da_du_ma(n=4): 'pa','po','sa','so','ta','to']\ [random.randint(0,11)] for i in range(n)]) -def populate(table, n, default=True): +def populate(table, n, default=True, compute=False): ell=Learner() #ell.learn(open('20417.txt','r').read()) #ell.save('frequencies.pickle') @@ -72,6 +72,8 @@ def populate(table, n, default=True): continue elif default and field.default: record[fieldname]=field.default + elif compute and field.compute: + continue elif field.type == 'text': record[fieldname]=ell.generate(random.randint(10,100),prefix=None) elif field.type == 'boolean':