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


Python FormSchema.read方法代碼示例

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


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

示例1: test_read_parameterized_widget_default

# 需要導入模塊: from plone.autoform.supermodel import FormSchema [as 別名]
# 或者: from plone.autoform.supermodel.FormSchema import read [as 別名]
    def test_read_parameterized_widget_default(self):
        from plone.autoform.widgets import ParameterizedWidget

        param_node = etree.Element('klass')
        param_node.text = 'custom'
        param2_node = etree.Element('placeholder')
        param2_node.text = 'help'
        widget_node = etree.Element(ns('widget', self.namespace))
        widget_node.append(param_node)
        widget_node.append(param2_node)
        field_node = etree.Element('field')
        field_node.append(widget_node)

        class IDummy(Interface):
            foo = zope.schema.TextLine(title=u'foo')

        handler = FormSchema()
        handler.read(field_node, IDummy, IDummy['foo'])

        widgets = IDummy.queryTaggedValue(WIDGETS_KEY)
        self.assertTrue(isinstance(widgets['foo'], ParameterizedWidget))
        self.assertTrue(widgets['foo'].widget_factory is None)
        self.assertIn('klass', widgets['foo'].params)
        self.assertEqual(widgets['foo'].params['klass'], 'custom')
        self.assertIn('placeholder', widgets['foo'].params)
        self.assertEqual(widgets['foo'].params['placeholder'], 'help')
開發者ID:plone,項目名稱:plone.autoform,代碼行數:28,代碼來源:test_supermodel_handler.py

示例2: test_read_multiple

# 需要導入模塊: from plone.autoform.supermodel import FormSchema [as 別名]
# 或者: from plone.autoform.supermodel.FormSchema import read [as 別名]
 def test_read_multiple(self):
     field_node1 = ElementTree.Element('field')
     field_node1.set(ns("widget", self.namespace), "z3c.form.browser.password.PasswordFieldWidget")
     field_node1.set(ns("mode", self.namespace), "hidden")
     field_node1.set(ns("omitted", self.namespace), "true")
     field_node1.set(ns("before", self.namespace), "somefield")
     
     field_node2 = ElementTree.Element('field')
     field_node2.set(ns("mode", self.namespace), "display")
     field_node2.set(ns("omitted", self.namespace), "yes")
     
     class IDummy(Interface):
         dummy1 = zope.schema.TextLine(title=u"dummy1")
         dummy2 = zope.schema.TextLine(title=u"dummy2")
     
     handler = FormSchema()
     handler.read(field_node1, IDummy, IDummy['dummy1'])
     handler.read(field_node2, IDummy, IDummy['dummy2'])
 
     self.assertEquals({'dummy1': 'z3c.form.browser.password.PasswordFieldWidget'},
         IDummy.getTaggedValue(WIDGETS_KEY))
     self.assertEquals([(Interface, 'dummy1', 'true'), (Interface, 'dummy2', 'yes')],
                       IDummy.getTaggedValue(OMITTED_KEY))
     self.assertEquals([(Interface, 'dummy1', 'hidden'), (Interface, 'dummy2', 'display')],
                       IDummy.getTaggedValue(MODES_KEY))
     self.assertEquals([('dummy1', 'before', 'somefield',)], IDummy.getTaggedValue(ORDER_KEY))
開發者ID:chaoflow,項目名稱:plone.autoform,代碼行數:28,代碼來源:test_supermodel_handler.py

示例3: test_read_no_data

# 需要導入模塊: from plone.autoform.supermodel import FormSchema [as 別名]
# 或者: from plone.autoform.supermodel.FormSchema import read [as 別名]
    def test_read_no_data(self):
        field_node = etree.Element('field')

        class IDummy(Interface):
            dummy = zope.schema.TextLine(title=u'dummy1')

        handler = FormSchema()
        handler.read(field_node, IDummy, IDummy['dummy'])

        self.assertEqual(None, IDummy.queryTaggedValue(WIDGETS_KEY))
        self.assertEqual(None, IDummy.queryTaggedValue(OMITTED_KEY))
        self.assertEqual(None, IDummy.queryTaggedValue(MODES_KEY))
        self.assertEqual(None, IDummy.queryTaggedValue(ORDER_KEY))
開發者ID:Martronic-SA,項目名稱:plone.autoform,代碼行數:15,代碼來源:test_supermodel_handler.py

示例4: test_read_values_with_interfaces

# 需要導入模塊: from plone.autoform.supermodel import FormSchema [as 別名]
# 或者: from plone.autoform.supermodel.FormSchema import read [as 別名]
    def test_read_values_with_interfaces(self):
        field_node1 = etree.Element('field')
        field_node1.set(
            ns('mode', self.namespace),
            'z3c.form.interfaces.IForm:hidden'
        )
        field_node1.set(
            ns('omitted', self.namespace),
            'z3c.form.interfaces.IForm:true'
        )

        field_node2 = etree.Element('field')
        field_node2.set(
            ns('mode', self.namespace),
            'z3c.form.interfaces.IForm:hidden '
            'z3c.form.interfaces.IEditForm:display'
        )
        field_node2.set(
            ns('omitted', self.namespace),
            'z3c.form.interfaces.IForm:true '
            'z3c.form.interfaces.IEditForm:false'
        )

        class IDummy(Interface):
            dummy1 = zope.schema.TextLine(title=u'dummy1')
            dummy2 = zope.schema.TextLine(title=u'dummy2')

        handler = FormSchema()
        handler.read(field_node1, IDummy, IDummy['dummy1'])
        handler.read(field_node2, IDummy, IDummy['dummy2'])

        expected_modes = [
            (IForm, u'dummy1', 'hidden'),
            (IForm, u'dummy2', 'hidden'),
            (IEditForm, u'dummy2', 'display')
        ]
        self.assertEqual(
            expected_modes,
            IDummy.queryTaggedValue(MODES_KEY)
        )
        expected_omitted = [
            (IForm, u'dummy1', 'true'),
            (IForm, u'dummy2', 'true'),
            (IEditForm, u'dummy2', 'false')
        ]
        self.assertEqual(
            expected_omitted,
            IDummy.queryTaggedValue(OMITTED_KEY)
        )
開發者ID:Martronic-SA,項目名稱:plone.autoform,代碼行數:51,代碼來源:test_supermodel_handler.py

示例5: test_read

# 需要導入模塊: from plone.autoform.supermodel import FormSchema [as 別名]
# 或者: from plone.autoform.supermodel.FormSchema import read [as 別名]
    def test_read(self):
        field_node = etree.Element('field')
        field_node.set(
            ns('widget', self.namespace),
            'z3c.form.browser.password.PasswordFieldWidget'
        )
        field_node.set(ns('mode', self.namespace), 'hidden')
        field_node.set(ns('omitted', self.namespace), 'true')
        field_node.set(ns('before', self.namespace), 'somefield')
        field_node.set(
            ns('validator', self.namespace),
            'plone.autoform.tests.test_utils.TestValidator'
        )

        class IDummy(Interface):
            dummy = zope.schema.TextLine(title=u'dummy')

        handler = FormSchema()
        handler.read(field_node, IDummy, IDummy['dummy'])

        self.assertEqual(
            {'dummy': 'z3c.form.browser.password.PasswordFieldWidget'},
            IDummy.getTaggedValue(WIDGETS_KEY)
        )
        self.assertEqual(
            [(Interface, 'dummy', 'true')],
            IDummy.getTaggedValue(OMITTED_KEY)
        )
        self.assertEqual(
            [(Interface, 'dummy', 'hidden')],
            IDummy.getTaggedValue(MODES_KEY)
        )
        self.assertEqual(
            [('dummy', 'before', 'somefield',)],
            IDummy.getTaggedValue(ORDER_KEY)
        )
        validator = getMultiAdapter(
            (None, None, None, IDummy['dummy'], None),
            IValidator
        )
        from plone.autoform.tests.test_utils import TestValidator
        assert isinstance(validator, TestValidator)
開發者ID:Martronic-SA,項目名稱:plone.autoform,代碼行數:44,代碼來源:test_supermodel_handler.py

示例6: test_read_multiple

# 需要導入模塊: from plone.autoform.supermodel import FormSchema [as 別名]
# 或者: from plone.autoform.supermodel.FormSchema import read [as 別名]
    def test_read_multiple(self):
        field_node1 = etree.Element('field')
        field_node1.set(
            ns('widget', self.namespace),
            'z3c.form.browser.password.PasswordFieldWidget'
        )
        field_node1.set(ns('mode', self.namespace), 'hidden')
        field_node1.set(ns('omitted', self.namespace), 'true')
        field_node1.set(ns('before', self.namespace), 'somefield')

        field_node2 = etree.Element('field')
        field_node2.set(ns('mode', self.namespace), 'display')
        field_node2.set(ns('omitted', self.namespace), 'yes')

        class IDummy(Interface):
            dummy1 = zope.schema.TextLine(title=u'dummy1')
            dummy2 = zope.schema.TextLine(title=u'dummy2')

        handler = FormSchema()
        handler.read(field_node1, IDummy, IDummy['dummy1'])
        handler.read(field_node2, IDummy, IDummy['dummy2'])

        self.assertEqual(
            {'dummy1': 'z3c.form.browser.password.PasswordFieldWidget'},
            IDummy.getTaggedValue(WIDGETS_KEY)
        )
        self.assertEqual(
            [(Interface, 'dummy1', 'true'), (Interface, 'dummy2', 'yes')],
            IDummy.getTaggedValue(OMITTED_KEY)
        )
        self.assertEqual(
            [(Interface, 'dummy1', 'hidden'),
             (Interface, 'dummy2', 'display')],
            IDummy.getTaggedValue(MODES_KEY)
        )
        self.assertEqual(
            [('dummy1', 'before', 'somefield',)],
            IDummy.getTaggedValue(ORDER_KEY)
        )
開發者ID:Martronic-SA,項目名稱:plone.autoform,代碼行數:41,代碼來源:test_supermodel_handler.py

示例7: test_read_parameterized_widget

# 需要導入模塊: from plone.autoform.supermodel import FormSchema [as 別名]
# 或者: from plone.autoform.supermodel.FormSchema import read [as 別名]
    def test_read_parameterized_widget(self):
        from plone.autoform.widgets import ParameterizedWidget

        param_node = etree.Element('klass')
        param_node.text = 'custom'
        widget_node = etree.Element(ns('widget', self.namespace))
        widget_node.set('type',
            'plone.autoform.tests.test_supermodel_handler.DummyWidget')
        widget_node.append(param_node)
        field_node = etree.Element('field')
        field_node.append(widget_node)

        class IDummy(Interface):
            foo = zope.schema.TextLine(title=u'foo')

        handler = FormSchema()
        handler.read(field_node, IDummy, IDummy['foo'])

        widgets = IDummy.queryTaggedValue(WIDGETS_KEY)
        self.assertTrue(isinstance(widgets['foo'], ParameterizedWidget))
        self.assertTrue(widgets['foo'].widget_factory is DummyWidget)
        self.assertEqual(widgets['foo'].params, {'klass': 'custom'})
開發者ID:upiq,項目名稱:plone.autoform,代碼行數:24,代碼來源:test_supermodel_handler.py


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