def put(self, req, form): """ Process requests received from FCKeditor to upload files, etc. """ if not fckeditor_available: return uid = getUid(req) # URL where the file can be fetched after upload user_files_path = '%(CFG_SITE_URL)s/record/%(recid)i/comments/attachments/get/%(uid)s' % \ {'uid': uid, 'recid': self.recid, 'CFG_SITE_URL': CFG_SITE_URL} # Path to directory where uploaded files are saved user_files_absolute_path = '%(CFG_PREFIX)s/var/data/comments/%(recid)s/%(uid)s' % \ {'uid': uid, 'recid': self.recid, 'CFG_PREFIX': CFG_PREFIX} # Create a Connector instance to handle the request conn = FCKeditorConnectorInvenio(form, recid=self.recid, uid=uid, allowed_commands=['QuickUpload'], allowed_types = ['File', 'Image', 'Flash', 'Media'], user_files_path = user_files_path, user_files_absolute_path = user_files_absolute_path) # Check that user can upload attachments for comments. user_info = collect_user_info(req) (auth_code, auth_msg) = check_user_can_attach_file_to_comments(user_info, self.recid) if user_info['email'] == 'guest' and not user_info['apache_user']: # User is guest: must login prior to upload data = conn.sendUploadResults(1, '', '', 'Please login before uploading file.') elif auth_code: # User cannot submit data = conn.sendUploadResults(1, '', '', 'Sorry, you are not allowed to submit files.') else: # Process the upload and get the response data = conn.doResponse() # Transform the headers into something ok for mod_python for header in conn.headers: if not header is None: if header[0] == 'Content-Type': req.content_type = header[1] else: req.headers_out[header[0]] = header[1] # Send our response req.send_http_header() req.write(data)