• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python forms.AddForm类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ptah.cms.forms.AddForm的典型用法代码示例。如果您正苦于以下问题:Python AddForm类的具体用法?Python AddForm怎么用?Python AddForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_addform_choosename

    def test_addform_choosename(self):
        from ptah.cms.forms import AddForm

        container = Container()

        form = AddForm(container, DummyRequest())

        name = form.chooseName(title='Test title')
        self.assertEqual(name, 'test-title')
开发者ID:runyaga,项目名称:ptah,代码行数:9,代码来源:test_forms.py


示例2: test_addform_update_type_check_context

    def test_addform_update_type_check_context(self):
        from ptah.cms.forms import AddForm

        container = Container()

        form = AddForm(container, DummyRequest())

        Content.__type__.permission = ptah.cms.NOT_ALLOWED
        form.tinfo = Content.__type__

        self.assertRaises(HTTPForbidden, form.update)
开发者ID:runyaga,项目名称:ptah,代码行数:11,代码来源:test_forms.py


示例3: test_addform_no_name_widgets

    def test_addform_no_name_widgets(self):
        from ptah.cms.forms import AddForm

        form = AddForm(Container(), DummyRequest())

        Content.__type__.permission = ptah.cms.NO_PERMISSION_REQUIRED
        form.tinfo = Content.__type__
        form.name_show = False
        form.update()

        self.assertIsNone(form.name_widgets)
开发者ID:runyaga,项目名称:ptah,代码行数:11,代码来源:test_forms.py


示例4: test_addform_basics

    def test_addform_basics(self):
        from ptah.cms.forms import AddForm

        container = Container()

        form = AddForm(container, DummyRequest())
        form.tinfo = Content.__type__

        self.assertIs(form.fields, Content.__type__.fieldset)
        self.assertEqual(form.label, 'Add %s'%Content.__type__.title)
        self.assertEqual(form.description, Content.__type__.description)
开发者ID:runyaga,项目名称:ptah,代码行数:11,代码来源:test_forms.py


示例5: test_addform_add_errors

    def test_addform_add_errors(self):
        from ptah.cms.forms import AddForm
        ptah.auth_service.set_userid(ptah.SUPERUSER_URI)

        container = Container()
        request = DummyRequest(
            POST = {'form.buttons.add': 'Add'})

        form = AddForm(container, request)
        Content.__type__.permission = ptah.cms.NO_PERMISSION_REQUIRED
        form.tinfo = Content.__type__
        form.update()

        self.assertIn('Please fix indicated errors.',
                      ptah.view.render_messages(request))
开发者ID:runyaga,项目名称:ptah,代码行数:15,代码来源:test_forms.py


示例6: test_addform_create

    def test_addform_create(self):
        from ptah.cms.forms import AddForm
        ptah.auth_service.set_userid(ptah.SUPERUSER_URI)

        form = AddForm(Container(), DummyRequest())

        Content.__type__.permission = ptah.cms.NO_PERMISSION_REQUIRED
        form.tinfo = Content.__type__
        form.update()

        content = form.create(**{'title': 'Test Content',
                                 '__name__': 'page.html'})

        self.assertEqual(content.__name__, 'page.html')
        self.assertIsInstance(content, Content)
开发者ID:runyaga,项目名称:ptah,代码行数:15,代码来源:test_forms.py


示例7: test_addform_update_suffix_from_type

    def test_addform_update_suffix_from_type(self):
        from ptah.cms.forms import AddForm

        container = Container()

        form = AddForm(container, DummyRequest())

        Content.__type__.name_suffix = '.xml'
        Content.__type__.permission = ptah.cms.NO_PERMISSION_REQUIRED

        form.tinfo = Content.__type__
        form.update()

        self.assertEqual(form.name_suffix, '.xml')

        Content.__type__.name_suffix = ''
        Content.__type__.permission = ptah.cms.NOT_ALLOWED
开发者ID:runyaga,项目名称:ptah,代码行数:17,代码来源:test_forms.py


示例8: test_addform_cancel

    def test_addform_cancel(self):
        from ptah.cms.forms import AddForm
        ptah.auth_service.set_userid(ptah.SUPERUSER_URI)

        container = Container()
        request = DummyRequest(
            POST = {'form.buttons.cancel': 'Cancel'})

        form = AddForm(container, request)

        Content.__type__.permission = ptah.cms.NO_PERMISSION_REQUIRED
        form.tinfo = Content.__type__

        res = form.update()

        self.assertIsInstance(res, HTTPFound)
        self.assertEqual(res.headers['location'], '.')
开发者ID:runyaga,项目名称:ptah,代码行数:17,代码来源:test_forms.py


示例9: test_addform_extract_with_errors

    def test_addform_extract_with_errors(self):
        from ptah.cms.forms import AddForm

        form = AddForm(Container(), DummyRequest(
            POST={'__name__': 't/est-content'}))

        Content.__type__.permission = ptah.cms.NO_PERMISSION_REQUIRED
        form.tinfo = Content.__type__
        form.update()

        data, errors = form.extract()

        self.assertEqual(len(errors), 2)
        self.assertEqual(errors[0].field.name, 'title')
        self.assertEqual(errors[0].msg, 'Required')
        self.assertEqual(errors[1].field.name, '__name__')
        self.assertEqual(errors[1].msg, "Names cannot contain '/'")
开发者ID:runyaga,项目名称:ptah,代码行数:17,代码来源:test_forms.py


示例10: test_addform_cancel

    def test_addform_cancel(self):
        from ptah.cms.forms import AddForm
        ptah.authService.set_userid(ptah.SUPERUSER_URI)

        container = Container()
        request = DummyRequest(
            POST = {'form.buttons.cancel': 'Cancel'})

        form = AddForm(container, request)

        Content.__type__.permission = ptah.cms.NO_PERMISSION_REQUIRED
        form.tinfo = Content.__type__

        try:
            form.update()
        except Exception, res:
            pass
开发者ID:blaflamme,项目名称:ptah,代码行数:17,代码来源:test_forms.py


示例11: test_addform_extract

    def test_addform_extract(self):
        from ptah.cms.forms import AddForm

        form = AddForm(Container(), DummyRequest(
            POST={'title': 'Test Content',
                  '__name__': 'test-content'}))

        Content.__type__.permission = ptah.cms.NO_PERMISSION_REQUIRED
        form.tinfo = Content.__type__
        form.update()

        data, errors = form.extract()

        self.assertEqual(len(errors), 0)
        self.assertEqual(len(data), 3)
        self.assertIn('title', data)
        self.assertIn('description', data)
        self.assertIn('__name__', data)
开发者ID:runyaga,项目名称:ptah,代码行数:18,代码来源:test_forms.py


示例12: test_addform_add

    def test_addform_add(self):
        from ptah.cms.forms import AddForm
        ptah.authService.set_userid(ptah.SUPERUSER_URI)

        container = Container()
        request = DummyRequest(
            POST = {'title': 'Test Content',
                    'form.buttons.add': 'Add'})
        request.root = container
        request.root.__path__ = '/'
        request.root.__root_path__ = '/'

        form = AddForm(container, request)

        Content.__type__.permission = ptah.cms.NO_PERMISSION_REQUIRED
        form.tinfo = Content.__type__

        try:
            form.update()
        except Exception, res:
            pass
开发者ID:blaflamme,项目名称:ptah,代码行数:21,代码来源:test_forms.py


示例13: test_addform_add

    def test_addform_add(self):
        from ptah.cms.forms import AddForm
        ptah.auth_service.set_userid(ptah.SUPERUSER_URI)

        container = Container()
        request = DummyRequest(
            POST = {'title': 'Test Content',
                    'form.buttons.add': 'Add'})
        request.root = container
        request.root.__path__ = '/'
        request.root.__root_path__ = '/'

        form = AddForm(container, request)

        Content.__type__.permission = ptah.cms.NO_PERMISSION_REQUIRED
        form.tinfo = Content.__type__

        res = form.update()

        self.assertIsInstance(res, HTTPFound)
        self.assertEqual(res.headers['location'], '/test-content/')
        self.assertIn('New content has been created.',
                      ptah.view.render_messages(request))
开发者ID:runyaga,项目名称:ptah,代码行数:23,代码来源:test_forms.py


示例14: test_addform_validate_name

    def test_addform_validate_name(self):
        from ptah.cms.forms import AddForm

        container = Container()
        container['test'] = Content()

        form = AddForm(container, DummyRequest())

        Content.__type__.permission = ptah.cms.NO_PERMISSION_REQUIRED
        form.tinfo = Content.__type__
        form.update()

        errors = []
        form.validate({'__name__': 'test'}, errors)

        self.assertEqual(len(errors), 1)
        self.assertIs(errors[0].field, form.name_widgets['__name__'])
        self.assertEqual(errors[0].msg, 'Name already in use')

        errors = []
        form.validate({'__name__': 'normal-name'}, errors)
        self.assertEqual(len(errors), 0)
开发者ID:runyaga,项目名称:ptah,代码行数:22,代码来源:test_forms.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python config.cleanup_system函数代码示例发布时间:2022-05-25
下一篇:
Python ptah.resolve函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap