當前位置: 首頁>>代碼示例>>Python>>正文


Python forms.EditorForm類代碼示例

本文整理匯總了Python中filebrowser.forms.EditorForm的典型用法代碼示例。如果您正苦於以下問題:Python EditorForm類的具體用法?Python EditorForm怎麽用?Python EditorForm使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了EditorForm類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: save_file

def save_file(request):
    """
    The POST endpoint to save a file in the file editor.

    Does the save and then redirects back to the edit page.
    """
    form = EditorForm(request.POST)
    is_valid = form.is_valid()
    path = form.cleaned_data.get('path')

    if request.POST.get('save') == "Save As":
        if not is_valid:
            return edit(request, path, form=form)
        else:
            data = dict(form=form)
            return render("saveas.mako", request, data)

    if not path:
        raise PopupException("No path specified")
    if not is_valid:
        return edit(request, path, form=form)

    if request.fs.exists(path):
        _do_overwrite_save(request.fs, path,
                           form.cleaned_data['contents'],
                           form.cleaned_data['encoding'])
    else:
        _do_newfile_save(request.fs, path,
                         form.cleaned_data['contents'],
                         form.cleaned_data['encoding'])

    messages.info(request, _('Saved %(path)s.') % {'path': os.path.basename(path)})
    """ Changing path to reflect the request path of the JFrame that will actually be returned."""
    request.path = urlresolvers.reverse("filebrowser.views.edit", kwargs=dict(path=path))
    return edit(request, path, form)
開發者ID:mobilipia,項目名稱:hue,代碼行數:35,代碼來源:views.py

示例2: save_file

def save_file(request):
    """
    The POST endpoint to save a file in the file editor.

    Does the save and then redirects back to the edit page.
    """
    form = EditorForm(request.POST)
    is_valid = form.is_valid()
    path = form.cleaned_data.get('path')

    if request.POST.get('save') == "Save As":
        if not is_valid:
            return edit(request, path, form=form)
        else:
            return render("saveas.mako", request, {'form': form})

    if not path:
        raise PopupException(_("No path specified"))
    if not is_valid:
        return edit(request, path, form=form)

    if request.fs.exists(path):
        do_overwrite_save(request.fs, path,
                           form.cleaned_data['contents'],
                           form.cleaned_data['encoding'])
    else:
        do_newfile_save(request.fs, path,
                         form.cleaned_data['contents'],
                         form.cleaned_data['encoding'])

    messages.info(request, _('Saved %(path)s.') % {'path': os.path.basename(path)})
    request.path = reverse("filebrowser.views.edit", kwargs=dict(path=path))
    return edit(request, path, form)
開發者ID:atupal,項目名稱:hue,代碼行數:33,代碼來源:views.py

示例3: save_file

def save_file(request):
    """
    The POST endpoint to save a file in the file editor.

    Does the save and then redirects back to the edit page.
    """
    form = EditorForm(request.POST)
    is_valid = form.is_valid()
    path = form.cleaned_data.get('path')

    if request.POST.get('save') == "Save As":
        if not is_valid:
            return edit(request, path, form=form)
        else:
            return render("saveas.mako", request, {'form': form})

    if not path:
        raise PopupException(_("No path specified"))
    if not is_valid:
        return edit(request, path, form=form)

    encoding = form.cleaned_data['encoding']
    data = form.cleaned_data['contents'].encode(encoding)

    try:
        if request.fs.exists(path):
            do_overwrite_save(request.fs, path, data)
        else:
            request.fs.create(path, overwrite=False, data=data)
    except WebHdfsException, e:
        raise PopupException(_("The file could not be saved"), detail=e.message.splitlines()[0])
開發者ID:perestu,項目名稱:hue,代碼行數:31,代碼來源:views.py


注:本文中的filebrowser.forms.EditorForm類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。