当前位置: 首页>>代码示例>>Python>>正文


Python FileListing.results_total方法代码示例

本文整理汇总了Python中filebrowser.base.FileListing.results_total方法的典型用法代码示例。如果您正苦于以下问题:Python FileListing.results_total方法的具体用法?Python FileListing.results_total怎么用?Python FileListing.results_total使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在filebrowser.base.FileListing的用法示例。


在下文中一共展示了FileListing.results_total方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: browse

# 需要导入模块: from filebrowser.base import FileListing [as 别名]
# 或者: from filebrowser.base.FileListing import results_total [as 别名]
def browse(request):
    """
    Browse Files/Directories.
    """
    
    query = request.GET.copy()
    abs_path = u'%s' % os.path.join(MEDIA_ROOT, DIRECTORY, query.get('dir', ''))

    filelisting = FileListing(abs_path,
        filter_func=filter_browse,
        sorting_by=query.get('o', DEFAULT_SORTING_BY),
        sorting_order=query.get('ot', DEFAULT_SORTING_ORDER))
    
    files = []
    if SEARCH_TRAVERSE and query.get("q"):
        listing = filelisting.files_walk_filtered()
    else:
        listing = filelisting.files_listing_filtered()

    # If we do a search, precompile the search pattern now
    do_search = query.get("q")
    if do_search:
        re_q = re.compile(query.get("q").lower(), re.M)

    filter_type = query.get('filter_type')
    filter_date = query.get('filter_date')
    
    for fileobject in listing:
        # date/type filter
        append = False
        if (not filter_type or fileobject.filetype == filter_type) and (not filter_date or get_filterdate(filter_date, fileobject.date or 0)):
            append = True
        # search
        if do_search and not re_q.search(fileobject.filename.lower()):
            append = False
        # append
        if append:
            files.append(fileobject)

    filelisting.results_total = len(listing)
    filelisting.results_current = len(files)
    
    p = Paginator(files, LIST_PER_PAGE)
    page_nr = request.GET.get('p', '1')
    try:
        page = p.page(page_nr)
    except (EmptyPage, InvalidPage):
        page = p.page(p.num_pages)

    return render_to_response('filebrowser/index.html', {
        'p': p,
        'page': page,
        'filelisting': filelisting,
        'query': query,
        'title': _(u'FileBrowser'),
        'settings_var': get_settings_var(),
        'breadcrumbs': get_breadcrumbs(query, query.get('dir', '')),
        'breadcrumbs_title': ""
    }, context_instance=Context(request))
开发者ID:dblundell,项目名称:django-filebrowser,代码行数:61,代码来源:views.py

示例2: browse

# 需要导入模块: from filebrowser.base import FileListing [as 别名]
# 或者: from filebrowser.base.FileListing import results_total [as 别名]
def browse(request):
    """
    Browse Files/Directories.
    """
    
    query = request.GET.copy()
    user = request.user.username
    abs_path = u'%s' % os.path.join(MEDIA_ROOT, DIRECTORY, user, query.get('dir', ''))
    if not abs_path.startswith(request.user.get_profile().media_path) and \
            not request.user.is_superuser:
        raise Http403("You may not access this directory")
    filelisting = FileListing(abs_path,
        filter_func=filter_browse,
        sorting_by=query.get('o', DEFAULT_SORTING_BY),
        sorting_order=query.get('ot', DEFAULT_SORTING_ORDER))
    
    files = []
    if SEARCH_TRAVERSE and query.get("q"):
        listing = filelisting.files_walk_filtered()
    else:
        listing = filelisting.files_listing_filtered()
    for fileobject in listing:
        # date/type filter
        append = False
        if fileobject.filetype == query.get('filter_type', fileobject.filetype) and get_filterdate(query.get('filter_date', ''), fileobject.date or 0):
            append = True
        # search
        if query.get("q") and not re.compile(query.get("q").lower(), re.M).search(fileobject.filename.lower()):
            append = False
        # append
        if append:
            files.append(fileobject)
    filelisting.results_total = filelisting.results_listing_filtered
    filelisting.results_current = len(files)
    
    p = Paginator(files, LIST_PER_PAGE)
    page_nr = request.GET.get('p', '1')
    try:
        page = p.page(page_nr)
    except (EmptyPage, InvalidPage):
        page = p.page(p.num_pages)
    
    return render_to_response('filebrowser/index.html', {
        'p': p,
        'page': page,
        'filelisting': filelisting,
        'query': query,
        'title': _(u'FileBrowser'),
        'settings_var': get_settings_var(),
        'breadcrumbs': get_breadcrumbs(query, query.get('dir', '')),
        'breadcrumbs_title': ""
    }, context_instance=Context(request))
开发者ID:omare,项目名称:exedjango,代码行数:54,代码来源:views.py

示例3: browse

# 需要导入模块: from filebrowser.base import FileListing [as 别名]
# 或者: from filebrowser.base.FileListing import results_total [as 别名]
    def browse(self, request):
        """
        Browse Files/Directories.
        """

        filter_re = []
        for exp in EXCLUDE:
           filter_re.append(re.compile(exp))
        for k,v in VERSIONS.iteritems():
            exp = (r'_%s(%s)') % (k, '|'.join(EXTENSION_LIST))
            filter_re.append(re.compile(exp))

        def filter_browse(item):
            filtered = item.filename.startswith('.')
            for re_prefix in filter_re:
                if re_prefix.search(item.filename):
                    filtered = True
            if filtered:
                return False
            return True
        
        query = request.GET.copy()
        path = u'%s' % os.path.join(self.directory, query.get('dir', ''))
        
        filelisting = FileListing(path,
            filter_func=filter_browse,
            sorting_by=query.get('o', DEFAULT_SORTING_BY),
            sorting_order=query.get('ot', DEFAULT_SORTING_ORDER),
            site=self)
        
        files = []
        if SEARCH_TRAVERSE and query.get("q"):
            listing = filelisting.files_walk_filtered()
        else:
            listing = filelisting.files_listing_filtered()
        
        # If we do a search, precompile the search pattern now
        do_search = query.get("q")
        if do_search:
            re_q = re.compile(query.get("q").lower(), re.M)
        
        filter_type = query.get('filter_type')
        filter_date = query.get('filter_date')
        
        for fileobject in listing:
            # date/type filter
            append = False
            if (not filter_type or fileobject.filetype == filter_type) and (not filter_date or get_filterdate(filter_date, fileobject.date or 0)):
                append = True
            # search
            if do_search and not re_q.search(fileobject.filename.lower()):
                append = False
            # append
            if append:
                files.append(fileobject)
        
        filelisting.results_total = len(listing)
        filelisting.results_current = len(files)
        
        p = Paginator(files, LIST_PER_PAGE)
        page_nr = request.GET.get('p', '1')
        try:
            page = p.page(page_nr)
        except (EmptyPage, InvalidPage):
            page = p.page(p.num_pages)
        
        return render_to_response('filebrowser/index.html', {
            'p': p,
            'page': page,
            'filelisting': filelisting,
            'query': query,
            'title': _(u'FileBrowser'),
            'is_popup': "pop" in request.REQUEST,   # ChangeList uses "pop"
            'settings_var': get_settings_var(directory=self.directory),
            'breadcrumbs': get_breadcrumbs(query, query.get('dir', '')),
            'breadcrumbs_title': "",
            'filebrowser_site': self
        }, context_instance=Context(request, current_app=self.name))
开发者ID:bsavelev,项目名称:django-filebrowser-no-grappelli-django14,代码行数:80,代码来源:sites.py

示例4: browse

# 需要导入模块: from filebrowser.base import FileListing [as 别名]
# 或者: from filebrowser.base.FileListing import results_total [as 别名]
    def browse(self, request):
        """
        Browse Files/Directories.
        """

        filter_re = []
        for exp in EXCLUDE:
            filter_re.append(re.compile(exp))
        for k, v in VERSIONS.iteritems():
            exp = (r"_%s(%s)") % (k, "|".join(EXTENSION_LIST))
            filter_re.append(re.compile(exp))

        def filter_browse(item):
            filtered = item.filename.startswith(".")
            for re_prefix in filter_re:
                if re_prefix.search(item.filename):
                    filtered = True
            if filtered:
                return False
            return True

        query = request.GET.copy()
        path = u"%s" % os.path.join(self.directory, query.get("dir", ""))

        filelisting = FileListing(
            path,
            filter_func=filter_browse,
            sorting_by=query.get("o", DEFAULT_SORTING_BY),
            sorting_order=query.get("ot", DEFAULT_SORTING_ORDER),
            site=self,
        )

        files = []
        if SEARCH_TRAVERSE and query.get("q"):
            listing = filelisting.files_walk_filtered()
        else:
            listing = filelisting.files_listing_filtered()

        # If we do a search, precompile the search pattern now
        do_search = query.get("q")
        if do_search:
            re_q = re.compile(query.get("q").lower(), re.M)

        filter_type = query.get("filter_type")
        filter_date = query.get("filter_date")

        for fileobject in listing:
            # date/type filter
            append = False
            if (not filter_type or fileobject.filetype == filter_type) and (
                not filter_date or get_filterdate(filter_date, fileobject.date or 0)
            ):
                append = True
            # search
            if do_search and not re_q.search(fileobject.filename.lower()):
                append = False
            # append
            if append:
                files.append(fileobject)

        filelisting.results_total = len(listing)
        filelisting.results_current = len(files)

        p = Paginator(files, LIST_PER_PAGE)
        page_nr = request.GET.get("p", "1")
        try:
            page = p.page(page_nr)
        except (EmptyPage, InvalidPage):
            page = p.page(p.num_pages)

        return render_to_response(
            "filebrowser/index.html",
            {
                "p": p,
                "page": page,
                "filelisting": filelisting,
                "query": query,
                "title": _(u"FileBrowser"),
                "settings_var": get_settings_var(directory=self.directory),
                "breadcrumbs": get_breadcrumbs(query, query.get("dir", "")),
                "breadcrumbs_title": "",
                "site": self,
            },
            context_instance=Context(request, current_app=self.name),
        )
开发者ID:hcarvalhoalves,项目名称:django-filebrowser,代码行数:87,代码来源:sites.py


注:本文中的filebrowser.base.FileListing.results_total方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。