How do I handle fieldnames in Metakit 2.0

Gordon McMillan gmcm at hypernet.com
Thu Mar 9 23:20:34 EST 2000


Anders Eriksson wrote:
> 
> I'm trying to create an application which uses Metakit 2.0 for python
> as the database. One of the things that I can't figure out is how to
> handle the field names or column names.
> 
> I have a database table with about 20 columns so I created a list
> which contains all the names for the columns.
> flist = ['name','email']
> 
>  But I can't use these names in the call to Metakit.
> 
> if I want to add a record (row) then I use the
> vw.append(name='Anders',email='ame at swipnet.se')
> 
> but if I want to build this statement dynamicle How do I do it. The
> column names (name, email) isn't a string and the whole expression
> (within the parenteses) isn't a string...

vw.append({'name':'Anders', 'email':'ame at swipnet.se'}) is 
another way.

You can pass in a dict, a list (better have the same attribute 
order as the view), or an object with attributes that match 
column names.

class A:
  pass

a = A()
a.name='Anders'
a.email='ame at swipnet.se'

vw.append(a)
 


- Gordon




More information about the Python-list mailing list