當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。