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


Python SelectWidget.multiple方法代碼示例

本文整理匯總了Python中plone.app.widgets.dx.SelectWidget.multiple方法的典型用法代碼示例。如果您正苦於以下問題:Python SelectWidget.multiple方法的具體用法?Python SelectWidget.multiple怎麽用?Python SelectWidget.multiple使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在plone.app.widgets.dx.SelectWidget的用法示例。


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

示例1: test_data_converter_tuple

# 需要導入模塊: from plone.app.widgets.dx import SelectWidget [as 別名]
# 或者: from plone.app.widgets.dx.SelectWidget import multiple [as 別名]
    def test_data_converter_tuple(self):
        from plone.app.widgets.dx import SelectWidget
        from plone.app.widgets.dx import SelectWidgetConverter

        field = Tuple(__name__='tuplefield',
                      value_type=Choice(__name__='selectfield',
                                        values=['one', 'two', 'three']))
        widget = SelectWidget(self.request)
        widget.field = field
        widget.multiple = True
        converter = SelectWidgetConverter(field, widget)

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

        self.assertEqual(
            converter.toFieldValue('one;two;three'),
            ('one', 'two', 'three'),
        )

        self.assertEqual(
            converter.toWidgetValue(tuple()),
            [],
        )

        self.assertEqual(
            converter.toWidgetValue(('one', 'two', 'three')),
            ['one', 'two', 'three'],
        )
開發者ID:hoka,項目名稱:plone.app.widgets,代碼行數:33,代碼來源:test_dx.py

示例2: test_widget_set_not_orderable

# 需要導入模塊: from plone.app.widgets.dx import SelectWidget [as 別名]
# 或者: from plone.app.widgets.dx.SelectWidget import multiple [as 別名]
 def test_widget_set_not_orderable(self):
     from plone.app.widgets.dx import SelectWidget
     widget = SelectWidget(self.request)
     # A set is not orderable
     widget.field = Set(
         __name__='selectfield',
         value_type=Choice(values=['one', 'two', 'three'])
     )
     widget.terms = widget.field.value_type.vocabulary
     widget.multiple = True
     self.assertEqual(
         {
             'multiple': True,
             'name': None,
             'pattern_options': {},
             'pattern': 'select2',
             'value': (),
             'items': [
                 ('one', 'one'),
                 ('two', 'two'),
                 ('three', 'three')
             ]
         },
         widget._base_args(),
     )
開發者ID:jianaijun,項目名稱:plone.app.widgets,代碼行數:27,代碼來源:test_dx.py

示例3: test_widget

# 需要導入模塊: from plone.app.widgets.dx import SelectWidget [as 別名]
# 或者: from plone.app.widgets.dx.SelectWidget import multiple [as 別名]
    def test_widget(self):
        from plone.app.widgets.dx import SelectWidget
        widget = SelectWidget(self.request)
        widget.field = Choice(
            __name__='selectfield',
            values=['one', 'two', 'three']
        )
        widget.terms = widget.field.vocabulary
        self.assertEqual(
            {
                'multiple': False,
                'name': None,
                'pattern_options': {},
                'pattern': 'select2',
                'value': (),
                'items': [
                    ('one', 'one'),
                    ('two', 'two'),
                    ('three', 'three')
                ]
            },
            widget._base_args(),
        )

        widget.multiple = True
        self.assertEqual(
            {
                'multiple': True,
                'name': None,
                'pattern_options': {'separator': ';', 'multiple': True},
                'pattern': 'select2',
                'value': (),
                'items': [
                    ('one', 'one'),
                    ('two', 'two'),
                    ('three', 'three')
                ]
            },
            widget._base_args(),
        )

        widget.value = 'one'
        self.assertEqual(
            {
                'multiple': True,
                'name': None,
                'pattern_options': {'separator': ';', 'multiple': True},
                'pattern': 'select2',
                'value': ('one'),
                'items': [
                    ('one', 'one'),
                    ('two', 'two'),
                    ('three', 'three')
                ]
            },
            widget._base_args(),
        )
開發者ID:hoka,項目名稱:plone.app.widgets,代碼行數:59,代碼來源:test_dx.py

示例4: test_widget_extract

# 需要導入模塊: from plone.app.widgets.dx import SelectWidget [as 別名]
# 或者: from plone.app.widgets.dx.SelectWidget import multiple [as 別名]
 def test_widget_extract(self):
     from plone.app.widgets.dx import SelectWidget
     widget = SelectWidget(self.request)
     widget.field = Choice(
         __name__='selectfield',
         values=['one', 'two', 'three']
     )
     widget.name = 'selectfield'
     self.request.form['selectfield'] = 'one'
     self.assertEquals(widget.extract(), ('one',))
     widget.multiple = True
     self.request.form['selectfield'] = 'one;two'
     self.assertEquals(widget.extract(), ('one;two', ))
開發者ID:hoka,項目名稱:plone.app.widgets,代碼行數:15,代碼來源:test_dx.py

示例5: test_data_converter_list

# 需要導入模塊: from plone.app.widgets.dx import SelectWidget [as 別名]
# 或者: from plone.app.widgets.dx.SelectWidget import multiple [as 別名]
    def test_data_converter_list(self):
        from plone.app.widgets.dx import SelectWidget
        from plone.app.widgets.dx import SelectWidgetConverter

        field = List(__name__='listfield',
                     value_type=Choice(__name__='selectfield',
                                       values=['one', 'two', 'three']))
        widget = SelectWidget(self.request)
        widget.field = field
        widget.multiple = True
        converter = SelectWidgetConverter(field, widget)

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

        self.assertEqual(
            converter.toFieldValue('one;two;three'),
            ['one', 'two', 'three'],
        )

        self.assertEqual(
            converter.toWidgetValue([]),
            [],
        )

        widget.separator = ','
        self.assertEqual(
            converter.toFieldValue('one,two,three'),
            ['one', 'two', 'three'],
        )
        self.assertRaises(
            LookupError,
            converter.toFieldValue, 'one;two;three'
        )

        self.assertEqual(
            converter.toWidgetValue(['one', 'two', 'three']),
            ['one', 'two', 'three']
        )
開發者ID:hoka,項目名稱:plone.app.widgets,代碼行數:43,代碼來源:test_dx.py


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