Exemple #1
0
 def appendChildren(self, root, parent_paths):
     res = []
     if IFRSFolder.providedBy(root):
         for child in root.values(True, True):
             if child.vpath in parent_paths:
                 res.append(self.obj2Data(child, parent_paths))
             else:
                 res.append(self.obj2Data(child))
     return res
 def appendChildren(self, root, parent_paths):
     res = []
     if IFRSFolder.providedBy(root):
         for child in root.values(True,True):
             if child.vpath in parent_paths:
                 res.append(self.obj2Data(child, parent_paths))
             else:
                 res.append(self.obj2Data(child))
     return res
    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
Exemple #4
0
    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 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
Exemple #6
0
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 rst_col_path(name, context):
    # 往上找左右列
    if context.__name__ == '':
        return '',''
    source_path = str(context.ospath)
    if IFRSFolder.providedBy(context):
        source_path = os.path.join(source_path, 'asf.rst')
    dc_main = context.metadata.get('main', {})
    col = dc_main.get(name, '')
    if col != '':
        return col, source_path
    if context.__parent__ == None: 
        return col, source_path
    return rst_col_path(name, context.__parent__)
Exemple #8
0
def rst_col_path(name, context):
    # 往上找左右列
    if context.__name__ == '':
        return '', ''
    source_path = str(context.ospath)
    if IFRSFolder.providedBy(context):
        source_path = os.path.join(source_path, 'asf.rst')
    dc_main = context.metadata.get('main', {})
    col = dc_main.get(name, '')
    if col != '':
        return col, source_path
    if context.__parent__ == None:
        return col, source_path
    return rst_col_path(name, context.__parent__)
    def singleBranchTree(self, root=''):
        """ 返回当前节点父节点,以及兄弟节点的清单
        用于显示初始的结构"""
        # get Root And Parents
        current = self.context

        nodes = [current] 
        while current.__parent__ != None:
            current = current.__parent__
            nodes.insert(0,current)

        parent_paths = []
        for node in nodes:
            if IFRSFolder.providedBy(node):
                parent_paths.append(node.vpath)
            else:
                break

        if IFRSFile.providedBy(root):
            return self.obj2Data(root.__parent__, parent_paths)

        return self.obj2Data(root, parent_paths)
Exemple #10
0
    def singleBranchTree(self, root=''):
        """ 返回当前节点父节点,以及兄弟节点的清单
        用于显示初始的结构"""
        # get Root And Parents
        current = self.context

        nodes = [current]
        while current.__parent__ != None:
            current = current.__parent__
            nodes.insert(0, current)

        parent_paths = []
        for node in nodes:
            if IFRSFolder.providedBy(node):
                parent_paths.append(node.vpath)
            else:
                break

        if IFRSFile.providedBy(root):
            return self.obj2Data(root.__parent__, parent_paths)

        return self.obj2Data(root, parent_paths)