def get_sub_time_paths(folder, root_vpath): """ 迭代查找整个子目录,找出所有的子路径 """ result = [] for obj in folder.values(True, False): dc = obj.metadata.get('dublin', {}) if IFRSFolder.providedBy(obj): result.extend(get_sub_time_paths(obj, root_vpath)) elif IFRSDocument.providedBy(obj): result.append((dc.get('created', ''), obj.vpath.replace(root_vpath + '/', ''), )) return result
def get_sub_time_paths(folder, root_vpath): """ 迭代查找整个子目录,找出所有的子路径 """ result = [] for obj in folder.values(True, False): dc = obj.metadata.get('dublin', {}) if IFRSFolder.providedBy(obj): result.extend(get_sub_time_paths(obj, root_vpath)) elif IFRSDocument.providedBy(obj): result.append(( dc.get('created', ''), obj.vpath.replace(root_vpath + '/', ''), )) return result
def obj2Data(self, obj, parent_paths=None): dc = obj.metadata.get('dublin',{}) name = obj.__name__ title = dc.get('title', obj.__name__) icon_url = '/static/folder.gif' view = '/view.html' url = model_url(obj, self.request) if IFRSFolder.providedBy(obj): view = '' else: url = url[:-1] if IFRSFile.providedBy(obj): icon_url = '/static/file.gif' if IFRSDocument.providedBy(obj): icon_url = '/static/document.gif' view = '' if IFRSImage.providedBy(obj): icon_url = '/static/image.gif' data = { 'name':name, 'url':url, 'view':view, 'icon':icon_url, 'title':title, 'children':[], 'flag':'' } if not IFRSFolder.providedBy(obj): data['children']=None elif parent_paths is not None: data['children'] = self.appendChildren(obj, parent_paths) if obj.vpath == self.context.vpath: data['flag']='current' elif obj.vpath + '/index.rst' == self.context.vpath: for child in data['children']: if 'index.rst' == data['name']: return data data['flag']='current' return data
def obj2Data(self, obj, parent_paths=None): dc = obj.metadata.get('dublin', {}) name = obj.__name__ title = dc.get('title', obj.__name__) icon_url = '/static/folder.gif' view = '/view.html' url = model_url(obj, self.request) if IFRSFolder.providedBy(obj): view = '' else: url = url[:-1] if IFRSFile.providedBy(obj): icon_url = '/static/file.gif' if IFRSDocument.providedBy(obj): icon_url = '/static/document.gif' view = '' if IFRSImage.providedBy(obj): icon_url = '/static/image.gif' data = { 'name': name, 'url': url, 'view': view, 'icon': icon_url, 'title': title, 'children': [], 'flag': '' } if not IFRSFolder.providedBy(obj): data['children'] = None elif parent_paths is not None: data['children'] = self.appendChildren(obj, parent_paths) if obj.vpath == self.context.vpath: data['flag'] = 'current' elif obj.vpath + '/index.rst' == self.context.vpath: for child in data['children']: if 'index.rst' == data['name']: return data data['flag'] = 'current' return data