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


Python CreateDirForm.errors['name']方法代码示例

本文整理汇总了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:
                 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.')])
开发者ID:bsavelev,项目名称:django-filebrowser-no-grappelli-django14,代码行数:28,代码来源:sites.py

示例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, 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))
开发者ID:Uznick,项目名称:django-filebrowser,代码行数:37,代码来源:sites.py


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