from Products.NaayaCore.constants import METATYPE_DISKFILE from naaya.core.utils import mimetype_from_filename def list_available_pathspecs(): out = [] for allowed_prefix in allowed_path_prefixes: root_path = resolve(allowed_prefix) for folder_path, folder_names, file_names in os.walk(root_path): for name in file_names: rel_path = path.join(folder_path, name)[len(root_path):] out.append(allowed_prefix + rel_path) return out manage_addDiskFile_html = PageTemplateFile('zpt/disk_file_add', globals()) manage_addDiskFile_html.list_available_pathspecs = list_available_pathspecs def manage_addDiskFile(self, id='', pathspec='', REQUEST=None): """ """ fs_path = resolve(pathspec) if not path.isfile(fs_path): raise ValueError("File not found %r (resolved to %r)" % (pathspec, fs_path)) if id == '': id = path.basename(fs_path) ob = DiskFile(id, pathspec) self._setObject(id, ob) if REQUEST is not None:
name_list.remove(name) def list_available_pathspecs(): out = [] for allowed_prefix in allowed_path_prefixes: root_path = resolve(allowed_prefix) for folder_path, folder_names, file_names in os.walk(root_path): remove_excluded(folder_names) remove_excluded(file_names) for name in file_names: rel_path = path.join(folder_path, name)[len(root_path):] out.append(allowed_prefix + rel_path) return out manage_addDiskFile_html = PageTemplateFile('zpt/disk_file_add', globals()) manage_addDiskFile_html.list_available_pathspecs = list_available_pathspecs def manage_addDiskFile(self, id='', pathspec='', REQUEST=None): """ """ fs_path = resolve(pathspec) if not path.isfile(fs_path): raise ValueError("File not found %r (resolved to %r)" % (pathspec, fs_path)) if id == '': id = path.basename(fs_path) ob = DiskFile(id, pathspec) self._setObject(id, ob) if REQUEST is not None:
""" from os import path from Globals import InitializeClass from AccessControl import ClassSecurityInfo from AccessControl.Permissions import view_management_screens from OFS.SimpleItem import SimpleItem from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.NaayaCore.constants import METATYPE_DISKTEMPLATE from DiskFile import list_available_pathspecs, resolve manage_addDiskTemplate_html = PageTemplateFile('zpt/disk_template_add', globals()) manage_addDiskTemplate_html.list_available_pathspecs = list_available_pathspecs def manage_addDiskTemplate(self, id='', pathspec='', REQUEST=None): """ """ fs_path = resolve(pathspec) if not path.isfile(fs_path): raise ValueError("File not found %r (resolved to %r)" % (pathspec, fs_path)) if id == '': filename = path.basename(fs_path) id = path.splitext(filename)[0] ob = DiskTemplate(id, pathspec) self._setObject(id, ob)