MetaKit issues with Python 2.2.1 CGI script

Mike C. Fletcher mcfletch at rogers.com
Wed Oct 2 23:43:56 EDT 2002


It's been a few years since I used MetaKit, but I think you want that 
data-definition line to be something like:

data = (reportingAgency,firstName,lastName,email,number)

or

data = {"reportingAgency":reportingAgency, ...}

Since meta-kit works with either sequences (such as a tuple or a list, 
(or a string, which is what you're seeing)) of values in column order, 
or a dictionary of columnName:columnValue pairs when doing an append to 
a table.  Meta-kit's raw API is _not_ like an SQL database where you 
want to dump everything into a string for the database to parse out 
again, it's a direct Python interface.

HTH,
Mike

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.'
> 
> I can create the database manually at the interactive shell and it
> works fine, so I know that part is working properly.  When I set the
> CGI script to print the line that would be passed to <view>.append()
> it looks fine.
> 
> Hoever, when I actually pass the line to .append() it takes the first
> character from the string and puts it into the first field.  The
> second character goes into the next field, etc.  For example:
> 
>     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)
>     db.commit()
> 
> When I run the above code, it stores the data like this:
> 
> Name                Value
> reportingAgency       r
> firstName             e
> lastName              p
> email                 o
> number                r
> 
> It takes the first item passed to the .append() and places one char in
> each field.  If I change the order the char passed into each field
> changes accordingly.  I have verified that the data being passed into
> the .append() is a str and there is no excess white space (not that it
> would matter).
> 
> Has anyone seen this before?  I am at a loss on what to try next.
> 
> Thanks for any suggestions,
> 
> Wayne

-- 
_______________________________________
   Mike C. Fletcher
   Designer, VR Plumber, Coder
   http://members.rogers.com/mcfletch/






More information about the Python-list mailing list