In the import controller
* underscores are missing from the form attributes
* The code tries to update EVERY table in db - and fails because they
do not all have uuid fields.
def importandsync():
form = FORM(INPUT(_type='file', _name='data'),
INPUT(_type='submit'))
if form.accepts(request.vars):
db.import_from_csv_file(form.vars.data.file,unique=False)
#for every table we want to sync
tables2sync = [ 'person', 'dog' ]
for table in tables2sync:
# for every uuid, delete all but the latest
items = db(db[table].id>0).select(db[table].id,
db[table].uuid, orderby= db[table].modifiedon, groupby=db[table].uuid)
for item in items:
db((db[table].uuid==item.uuid)& (db[table].id!
=item.id)).delete()
return dict(form=form)
Once these changes are made, IT WORKS VERY NICELY and does exactly
what I need to do.
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.