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


Python dx.AjaxSelectWidget类代码示例

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


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

示例1: test_data_converter_tuple

    def test_data_converter_tuple(self):
        from plone.app.widgets.dx import AjaxSelectWidget
        from plone.app.widgets.dx import AjaxSelectWidgetConverter

        field = Tuple(__name__='tuplefield', value_type=TextLine())
        widget = AjaxSelectWidget(self.request)
        widget.field = field
        converter = AjaxSelectWidgetConverter(field, widget)

        self.assertEqual(
            converter.toFieldValue(''),
            field.missing_value,
        )

        self.assertEqual(
            converter.toFieldValue('123;456;789'),
            ('123', '456', '789'),
        )

        self.assertEqual(
            converter.toWidgetValue(tuple()),
            None,
        )

        self.assertEqual(
            converter.toWidgetValue(('123', '456', '789')),
            '123;456;789',
        )
开发者ID:hoka,项目名称:plone.app.widgets,代码行数:28,代码来源:test_dx.py

示例2: test_widget_addform_url_on_addform

    def test_widget_addform_url_on_addform(self):
        from plone.app.widgets.dx import AjaxSelectWidget
        widget = AjaxSelectWidget(self.request)
        form = Mock()
        from zope.interface import directlyProvides
        from z3c.form.interfaces import IAddForm
        directlyProvides(form, IAddForm)
        form.request = {'URL': 'http://addform_url'}
        widget.form = form
        self.assertEqual(
            {
                'name': None,
                'value': u'',
                'pattern': 'select2',
                'pattern_options': {'separator': ';'},
            },
            widget._base_args(),
        )
        widget.vocabulary = 'vocabulary1'
        self.assertEqual(
            {
                'name': None,
                'value': u'',
                'pattern': 'select2',
                'pattern_options': {
                    'separator': ';',
                    'vocabularyUrl':
                    'http://addform_url/@@getVocabulary?name=vocabulary1'}

            },
            widget._base_args(),
        )
开发者ID:hoka,项目名称:plone.app.widgets,代码行数:32,代码来源:test_dx.py

示例3: test_widget_tuple_orderable

 def test_widget_tuple_orderable(self):
     from plone.app.widgets.dx import AjaxSelectWidget
     widget = AjaxSelectWidget(self.request)
     widget.field = Tuple(__name__='selectfield')
     self.assertEqual(
         {
             'name': None,
             'value': u'',
             'pattern': 'select2',
             'pattern_options': {'orderable': True, 'separator': ';'},
         },
         widget._base_args(),
     )
开发者ID:hoka,项目名称:plone.app.widgets,代码行数:13,代码来源:test_dx.py

示例4: test_widget_set_not_orderable

 def test_widget_set_not_orderable(self):
     from plone.app.widgets.dx import AjaxSelectWidget
     widget = AjaxSelectWidget(self.request)
     # A set is not orderable
     widget.field = Set(__name__='selectfield')
     self.assertEqual(
         {
             'name': None,
             'value': None,
             'pattern': 'select2',
             'pattern_options': {'separator': ';'},
         },
         widget._base_args(),
     )
开发者ID:jianaijun,项目名称:plone.app.widgets,代码行数:14,代码来源:test_dx.py

示例5: test_widget_choice

 def test_widget_choice(self):
     from plone.app.widgets.dx import AjaxSelectWidget
     from zope.schema.interfaces import ISource
     widget = AjaxSelectWidget(self.request)
     source = Mock()
     alsoProvides(source, ISource)
     widget.field = Choice(__name__='choicefield', source=source)
     widget.name = 'choicefield'
     self.assertEqual(
         {
             'name': 'choicefield',
             'value': u'',
             'pattern': 'select2',
             'pattern_options': {
                 'separator': ';',
                 'maximumSelectionSize': 1,
                 'vocabularyUrl':
                 'http://127.0.0.1/++widget++choicefield/@@getSource',
                 },
         },
         widget._base_args(),
     )
开发者ID:hoka,项目名称:plone.app.widgets,代码行数:22,代码来源:test_dx.py

示例6: test_widget

    def test_widget(self):
        from plone.app.widgets.dx import AjaxSelectWidget
        widget = AjaxSelectWidget(self.request)
        widget.update()
        self.assertEqual(
            {
                'name': None,
                'value': u'',
                'pattern': 'select2',
                'pattern_options': {'separator': ';'},
            },
            widget._base_args()
        )

        widget.vocabulary = 'example'
        self.assertEqual(
            widget._base_args(),
            {
                'name': None,
                'value': u'',
                'pattern': 'select2',
                'pattern_options': {
                    'vocabularyUrl': '/@@getVocabulary?name=example',
                    'separator': ';'
                },
            }
        )

        widget.value = 'three;two'
        self.assertEqual(
            widget._base_args(),
            {
                'name': None,
                'value': 'three;two',
                'pattern': 'select2',
                'pattern_options': {
                    'vocabularyUrl': '/@@getVocabulary?name=example',
                    'initialValues': {'three': u'Three', 'two': u'Two'},
                    'separator': ';'
                },
            }
        )
开发者ID:hoka,项目名称:plone.app.widgets,代码行数:42,代码来源:test_dx.py


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