def document_entry(self, parent_path, ob_id, filename, data_file, title, description, date, userid): from StringIO import StringIO assert isinstance(data_file, StringIO) data_file.filename = filename bf = make_blobfile(data_file, content_type=mimetype_from_filename(filename), removed=False, timestamp=datetime(date.year, date.month, date.day)) parent = get_parent(self.context, parent_path) orig_path = parent_path + '/' + ob_id if orig_path in self.rename: ob_path = self.rename.get(orig_path) the_file = self.context.restrictedTraverse(ob_path) else: kwargs = { 'id': ob_id, 'contributor': userid, 'releasedate': nydateformat(date), 'title': title, 'description': description, '_send_notifications': False, } assert ob_id not in parent.objectIds() the_file_id = addNyBFile(parent, **kwargs) self.rename[orig_path] = parent_path + '/' + the_file_id the_file = parent[the_file_id] the_file._versions.append(bf) #print>>self.report, "file: %r" % path_in_site(the_file) self.count['files'] += 1
def _get_mime_type(self): return mimetype_from_filename(self.pathspec, 'application/octet-stream')