[Zope] upload a file to external method

garry saddington garry at joydiv.fsnet.co.uk
Fri Aug 6 16:04:20 EDT 2004


I have a form which uploads a file called students.csv and i want to feed this 
file into an external method. As far as I have got is below - this is the 
contents of the external method, can anyone help correct this as it does not 
work. Hopefully it should read a .csv file, output a dictionary and feed this 
to the ZSQL method writestudents.

## Script (Python) "handlestudents"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=REQUEST
##title=
##

def students(self,REQUEST):
  import csv
  stud=REQUEST.form["students.csv"]
  fieldnames=["firsname","surname", "year", "form","gender"]
  reader = csv.DictReader(stud,fieldnames)
  for row in reader:
    self.writestudents(row)

regards
garry



More information about the Zope mailing list