--- ObjectManager.py.orig Thu Jul 22 11:19:22 1999 +++ ObjectManager.py Tue Nov 30 06:24:26 1999 @@ -464,14 +464,28 @@ manage_importExportForm=HTMLFile('importExport',globals()) - def manage_importObject(self, file, REQUEST=None): + def manage_importObject(self, file=None, uploadfile=None, upload=None, REQUEST=None): """Import an object from a file""" - dirname, file=os.path.split(file) - if dirname: - raise 'Bad Request', 'Invalid file name %s' % file - file=os.path.join(INSTANCE_HOME, 'import', file) - if not os.path.exists(file): - raise 'Bad Request', 'File does not exist: %s' % file + if upload: + file=uploadfile + if file and file.filename: + # check file size + # We do not need to check anything else, because if the file is invalid, + # the import machinery will raise an error + file.seek(0, 2) + if file.tell() > 65536: # the limit is 64K. is this enough or too much ??? + raise 'Bad Request', 'Files imported can not be over 64K in size' + file.seek(0, 0) + else: + raise 'Bad Request', 'You must specify the file to upload' + else: + dirname, file=os.path.split(file) + if dirname: + raise 'Bad Request', 'Invalid file name %s' % file + file=os.path.join(INSTANCE_HOME, 'import', file) + if not os.path.exists(file): + raise 'Bad Request', 'File does not exist: %s' % file + ob=self._p_jar.importFile(file) if REQUEST: self._verifyObjectPaste(ob, REQUEST) id=ob.id