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


Python FlushForm.is_valid方法代码示例

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


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

示例1: hera

# 需要导入模块: from hera.contrib.django_forms import FlushForm [as 别名]
# 或者: from hera.contrib.django_forms.FlushForm import is_valid [as 别名]
def hera(request):
    form = FlushForm(initial={"flushprefix": site_settings.SITE_URL})

    boxes = []
    configured = False  # Default to not showing the form.
    for i in site_settings.HERA:
        hera = get_hera(i)
        r = {"location": urlparse(i["LOCATION"])[1], "stats": False}
        if hera:
            r["stats"] = hera.getGlobalCacheInfo()
            configured = True
        boxes.append(r)

    if not configured:
        messages.error(request, "Hera is not (or mis-)configured.")
        form = None

    if request.method == "POST" and hera:
        form = FlushForm(request.POST)
        if form.is_valid():
            expressions = request.POST["flushlist"].splitlines()

            for url in expressions:
                num = flush_urls([url], request.POST["flushprefix"], True)
                msg = "Flushed %d objects from front end cache for: %s" % (len(num), url)
                log.info("[Hera] (user:%s) %s" % (request.user, msg))
                messages.success(request, msg)

    return jingo.render(request, "zadmin/hera.html", {"form": form, "boxes": boxes})
开发者ID:james4388,项目名称:zamboni,代码行数:31,代码来源:views.py

示例2: hera

# 需要导入模块: from hera.contrib.django_forms import FlushForm [as 别名]
# 或者: from hera.contrib.django_forms.FlushForm import is_valid [as 别名]
def hera(request):
    form = FlushForm(initial={'flushprefix': settings.SITE_URL})

    boxes = []
    configured = False  # Default to not showing the form.
    for i in settings.HERA:
        hera = get_hera(i)
        r = {'location': urlparse(i['LOCATION'])[1], 'stats': False}
        if hera:
            r['stats'] = hera.getGlobalCacheInfo()
            configured = True
        boxes.append(r)

    if not configured:
        messages.error(request, "Hera is not (or mis-)configured.")
        form = None

    if request.method == 'POST' and hera:
        form = FlushForm(request.POST)
        if form.is_valid():
            expressions = request.POST['flushlist'].splitlines()

            for url in expressions:
                num = flush_urls([url], request.POST['flushprefix'], True)
                msg = ("Flushed %d objects from front end cache for: %s"
                       % (len(num), url))
                log.info("[Hera] (user:%s) %s" % (request.user, msg))
                messages.success(request, msg)

    return jingo.render(request, 'zadmin/hera.html',
                        {'form': form, 'boxes': boxes})
开发者ID:darkwing,项目名称:zamboni,代码行数:33,代码来源:views.py

示例3: hera

# 需要导入模块: from hera.contrib.django_forms import FlushForm [as 别名]
# 或者: from hera.contrib.django_forms.FlushForm import is_valid [as 别名]
def hera(request):
    form = FlushForm(initial={'flushprefix': site_settings.SITE_URL})

    hera = get_hera()

    if not hera:
        messages.error(request, "Hera is not (or mis-)configured.")
        form = None
        stats = None
    else:
        stats = hera.getGlobalCacheInfo()

    if request.method == 'POST' and hera:
        form = FlushForm(request.POST)
        if form.is_valid():
            expressions = request.POST['flushlist'].splitlines()

            for url in expressions:
                num = flush_urls([url], request.POST['flushprefix'], True)
                msg = ("Flushed %d objects from front end cache for: %s"
                       % (len(num), url))
                log.info("[Hera] (user:%s) %s" % (request.user, msg))
                messages.success(request, msg)

    return jingo.render(request, 'zadmin/hera.html',
                        {'form': form, 'stats': stats})
开发者ID:jaliste,项目名称:zamboni,代码行数:28,代码来源:views.py


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