def import_document(document_type):
 if (document_type in ('map', 'image')):
  image = True
  doc_table = s3db.doc_image
 else:
  image = False
  doc_table = s3db.doc_document
 post_vars = request.post_vars
 file = post_vars.file
 real_filename = file.filename
 new_filename = doc_table.file.store(file, real_filename)
 date = request.utcnow
 location_id = post_vars.location
 vdoc_table = s3db.vulnerability_document
 id = vdoc_table.insert(document_type=document_type, date=date, location_id=location_id)
 record = dict(id=id)
 s3db.update_super(vdoc_table, record)
 doc_table.insert(doc_id=record['doc_id'], file=new_filename, name=real_filename, date=date, comments=post_vars.desc, location_id=location_id)
 if image:
  s3db.pr_image_modify(file.file, new_filename, real_filename, size=(250, 250))

def import_document ( document_type ) : if ( document_type in ( 'map' , 'image' ) ) : image = True doc_table = s3db . doc_image else : image = False doc_table = s3db . doc_document post_vars = request . post_vars file = post_vars . file real_filename = file . filename new_filename = doc_table . file . store ( file , real_filename ) date = request . utcnow location_id = post_vars . location vdoc_table = s3db . vulnerability_document id = vdoc_table . insert ( document_type = document_type , date = date , location_id = location_id ) record = dict ( id = id ) s3db . update_super ( vdoc_table , record ) doc_table . insert ( doc_id = record [ 'doc_id' ] , file = new_filename , name = real_filename , date = date , comments = post_vars . desc , location_id = location_id ) if image : s3db . pr_image_modify ( file . file , new_filename , real_filename , size = ( 250 , 250 ) )
controller to store a document .