本文整理汇总了Python中filebrowser.forms.CreateDirForm.errors["name"]方法的典型用法代码示例。如果您正苦于以下问题:Python CreateDirForm.errors["name"]方法的具体用法?Python CreateDirForm.errors["name"]怎么用?Python CreateDirForm.errors["name"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类filebrowser.forms.CreateDirForm
的用法示例。
在下文中一共展示了CreateDirForm.errors["name"]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createdir
# 需要导入模块: from filebrowser.forms import CreateDirForm [as 别名]
# 或者: from filebrowser.forms.CreateDirForm import errors["name"] [as 别名]
def createdir(self, request):
"Create Directory"
from filebrowser.forms import CreateDirForm
query = request.GET
path = u"%s" % os.path.join(self.directory, query.get("dir", ""))
if request.method == "POST":
form = CreateDirForm(path, request.POST, filebrowser_site=self)
if form.is_valid():
server_path = os.path.join(path, form.cleaned_data["name"])
try:
signals.filebrowser_pre_createdir.send(
sender=request, path=server_path, name=form.cleaned_data["name"], site=self
)
self.storage.makedirs(server_path)
signals.filebrowser_post_createdir.send(
sender=request, path=server_path, name=form.cleaned_data["name"], site=self
)
messages.add_message(
request,
messages.SUCCESS,
_("The Folder %s was successfully created.") % form.cleaned_data["name"],
)
redirect_url = reverse("filebrowser:fb_browse", current_app=self.name) + query_helper(
query, "ot=desc,o=date", "ot,o,filter_type,filter_date,q,p"
)
return HttpResponseRedirect(redirect_url)
except OSError as e:
errno = e.args[0]
if errno == 13:
form.errors["name"] = forms.util.ErrorList([_("Permission denied.")])
else:
form.errors["name"] = forms.util.ErrorList([_("Error creating folder.")])
else:
form = CreateDirForm(path, filebrowser_site=self)
return render_to_response(
"filebrowser/createdir.html",
{
"form": form,
"query": query,
"title": _(u"New Folder"),
"settings_var": get_settings_var(directory=self.directory),
"breadcrumbs": get_breadcrumbs(query, query.get("dir", "")),
"breadcrumbs_title": _(u"New Folder"),
"filebrowser_site": self,
},
context_instance=Context(request, current_app=self.name),
)
示例2: createdir
# 需要导入模块: from filebrowser.forms import CreateDirForm [as 别名]
# 或者: from filebrowser.forms.CreateDirForm import errors["name"] [as 别名]
def createdir(self, request):
"""
Create Directory.
"""
from filebrowser.forms import CreateDirForm
query = request.GET
path = u"%s" % os.path.join(self.directory, query.get("dir", ""))
if request.method == "POST":
form = CreateDirForm(path, request.POST, site=self)
if form.is_valid():
server_path = os.path.join(path, form.cleaned_data["name"])
try:
self.filebrowser_pre_createdir.send(
sender=request, path=server_path, name=form.cleaned_data["name"]
)
self.storage.makedirs(server_path)
# os.mkdir(server_path)
# os.chmod(server_path, 0775) # ??? PERMISSIONS
self.filebrowser_post_createdir.send(
sender=request, path=server_path, name=form.cleaned_data["name"]
)
messages.add_message(
request,
messages.SUCCESS,
_("The Folder %s was successfully created.") % form.cleaned_data["name"],
)
redirect_url = reverse("filebrowser:fb_browse", current_app=self.name) + query_helper(
query, "ot=desc,o=date", "ot,o,filter_type,filter_date,q,p"
)
return HttpResponseRedirect(redirect_url)
except OSError, (errno, strerror):
if errno == 13:
form.errors["name"] = forms.util.ErrorList([_("Permission denied.")])
else:
form.errors["name"] = forms.util.ErrorList([_("Error creating folder.")])