I'd appreciate some comments on my use of globals and the map function.
The idea here is that (simple) Metakit database definitions can be
loaded dynamically from another Metakit database detifintion. (Yes this
would likely be easier with a SQL database, don't ask!) Nasty code
ahead: <br>
<br>
import metakit<br>
import marshal<br>
<br>
db = metakit.storage('<a href="http://addy.mk">addy.mk</a>',1)<br>
dbs = db.getas('dbs[db:S,marshal:B]')<br>
<br>
def li(i):<br>
i = i[:-2]<br>
return i<br>
<br>
def selectDB(f):<br>
if f.has_key('db'):<br>
d = []<br>
d['db'] = f.get('db').value<br>
id = dbs.find(d)<br>
if id != -1:<br>
global desc, vw, primaryKey<br>
desc
=
marshal.loads(dbs[id].marshal)
<br>
vw = db.getas('%s%s' % (dbs[id].db,desc))<br>
desc = map(li,desc) <br>
primaryKey =
desc[0]
<br>
return desc, vw, primaryKey <br>
else:<br>
error(-1)
<br>
else:<br>
error(select=None) <br>