MetaKit issues with Python 2.2.1 CGI script
Gordon McMillan
gmcm at hypernet.com
Thu Oct 3 09:09:08 EDT 2002
[posted and mailed]
Wayne Pierce wrote:
> I have been working on a CGI script that is supposed store data into a
> MetaKit database, but is only storing one character per 'field.'
[...]
> import metakit
> db = metakit.storage("officer.mk",1)
> ovw = db.view("officer")
>
> data =
> "reportingAgency='%s',firstName='%s',lastName='%s',email='%s',number
> ='%s'"
> % (reportingAgency,firstName,lastName,email,number)
>
> /*
> The above data is parsed from a CGI form.
> */
>
> ovw.append(data)
You are passing one argument (a string) to append. As a desperate
fallback, it's treating it as a sequence.
ovw.append(reportingAgency=reportingAgency, firstName=firstName,
lastName=lastName, email=email, number=number)
is what you want. There's no need for any string substition.
If you don't know what fields will be present at runtime, then
construct a dictionary:
d = {'reportingAgency':reportingAgency,
.... }
ovw.append(d)
-- Gordon
http://www.mcmillan-inc.com/
More information about the Python-list
mailing list