'Find, rename and store an uploaded file and return it\'s
new pathname'

def _store_file(self, table, fieldname, rowindex):

    field = table[fieldname]
    formname = self._formname()
    upload = ('upload_%s_%s_%s' % (formname, fieldname, rowindex))
    post_vars = current.request.post_vars
    if (upload in post_vars):
        f = post_vars[upload]
        if hasattr(f, 'file'):
            (sfile, ofilename) = (f.file, f.filename)
            nfilename = field.store(sfile, ofilename, field.uploadfolder)
            self.upload[upload] = nfilename
            return nfilename
        elif isinstance(f, basestring):
            return f
    return None
