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


Python FormSchema.write方法代碼示例

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


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

示例1: test_write_no_data

# 需要導入模塊: from plone.autoform.supermodel import FormSchema [as 別名]
# 或者: from plone.autoform.supermodel.FormSchema import write [as 別名]
 def test_write_no_data(self):
     field_node = ElementTree.Element('field')
     
     class IDummy(Interface):
         dummy = zope.schema.TextLine(title=u"dummy1")
         
     handler = FormSchema()
     handler.write(field_node, IDummy, IDummy['dummy'])
     
     self.assertEquals(None, field_node.get(ns("widget", self.namespace)))
     self.assertEquals(None, field_node.get(ns("omitted", self.namespace)))
     self.assertEquals(None, field_node.get(ns("mode", self.namespace)))
     self.assertEquals(None, field_node.get(ns("before", self.namespace)))
開發者ID:chaoflow,項目名稱:plone.autoform,代碼行數:15,代碼來源:test_supermodel_handler.py

示例2: test_write_no_data

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

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

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

        self.assertEqual(None, field_node.find(ns('widget', self.namespace)))
        self.assertEqual(None, field_node.get(ns('omitted', self.namespace)))
        self.assertEqual(None, field_node.get(ns('mode', self.namespace)))
        self.assertEqual(None, field_node.get(ns('before', self.namespace)))
開發者ID:Martronic-SA,項目名稱:plone.autoform,代碼行數:15,代碼來源:test_supermodel_handler.py

示例3: test_write_parameterized_widget_default

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

        class IDummy(Interface):
            dummy1 = zope.schema.Text(title=u'dummy1')
        IDummy.setTaggedValue(WIDGETS_KEY, {'dummy1': pw})

        fieldNode = etree.Element('field')
        handler = FormSchema()
        handler.write(fieldNode, IDummy, IDummy['dummy1'])

        self.assertEquals(etree.tostring(fieldNode),
            '<field/>')
開發者ID:upiq,項目名稱:plone.autoform,代碼行數:16,代碼來源:test_supermodel_handler.py

示例4: test_write_parameterized_widget_default_with_handler

# 需要導入模塊: from plone.autoform.supermodel import FormSchema [as 別名]
# 或者: from plone.autoform.supermodel.FormSchema import write [as 別名]
    def test_write_parameterized_widget_default_with_handler(self):
        from plone.autoform.widgets import ParameterizedWidget
        pw = ParameterizedWidget(None, klass='custom')

        class IDummy(Interface):
            dummy1 = zope.schema.Text(title=u'dummy1')
        IDummy.setTaggedValue(WIDGETS_KEY, {'dummy1': pw})

        fieldNode = etree.Element('field')
        handler = FormSchema()
        handler.write(fieldNode, IDummy, IDummy['dummy1'])

        self.assertEquals(etree.tostring(fieldNode),
            '<field><ns0:widget xmlns:ns0="http://namespaces.plone.org/supermodel/form">'
            '<klass>custom</klass></ns0:widget></field>')
開發者ID:upiq,項目名稱:plone.autoform,代碼行數:17,代碼來源:test_supermodel_handler.py

示例5: test_write_parameterized_widget_string

# 需要導入模塊: from plone.autoform.supermodel import FormSchema [as 別名]
# 或者: from plone.autoform.supermodel.FormSchema import write [as 別名]
    def test_write_parameterized_widget_string(self):
        from plone.autoform.widgets import ParameterizedWidget
        pw = ParameterizedWidget('foo')

        class IDummy(Interface):
            dummy1 = zope.schema.Text(title=u'dummy1')
        IDummy.setTaggedValue(WIDGETS_KEY, {'dummy1': pw})

        fieldNode = etree.Element('field')
        handler = FormSchema()
        handler.write(fieldNode, IDummy, IDummy['dummy1'])

        self.assertEqual(
            etree.tostring(fieldNode),
            '<field><ns0:widget'
            ' xmlns:ns0="http://namespaces.plone.org/supermodel/form"'
            ' type="foo"/></field>'
        )
開發者ID:Martronic-SA,項目名稱:plone.autoform,代碼行數:20,代碼來源:test_supermodel_handler.py

示例6: test_write_partial

# 需要導入模塊: from plone.autoform.supermodel import FormSchema [as 別名]
# 或者: from plone.autoform.supermodel.FormSchema import write [as 別名]
 def test_write_partial(self):
     field_node = ElementTree.Element('field')
     
     class IDummy(Interface):
         dummy = zope.schema.TextLine(title=u"dummy1")
     
     IDummy.setTaggedValue(WIDGETS_KEY, {'dummy': 'SomeWidget'})
     IDummy.setTaggedValue(OMITTED_KEY, [(Interface, 'dummy2', 'true')])
     IDummy.setTaggedValue(MODES_KEY, [(Interface, 'dummy', 'display'), (Interface, 'dummy2', 'hidden')])
     IDummy.setTaggedValue(ORDER_KEY, [])
     
     handler = FormSchema()
     handler.write(field_node, IDummy, IDummy['dummy'])
     
     self.assertEquals("SomeWidget", field_node.get(ns("widget", self.namespace)))
     self.assertEquals(None, field_node.get(ns("omitted", self.namespace)))
     self.assertEquals("display", field_node.get(ns("mode", self.namespace)))
     self.assertEquals(None, field_node.get(ns("before", self.namespace)))
開發者ID:chaoflow,項目名稱:plone.autoform,代碼行數:20,代碼來源:test_supermodel_handler.py

示例7: test_write_values_with_interfaces

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

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

        modes_values = [
            (IForm, u'dummy1', 'hidden'),
            (IForm, u'dummy2', 'hidden'),
            (IEditForm, u'dummy2', 'display')
        ]
        IDummy.setTaggedValue(MODES_KEY, modes_values)
        omitted_values = [
            (IForm, u'dummy1', 'true'),
            (IForm, u'dummy2', 'true'),
            (IEditForm, u'dummy2', 'false')
        ]
        IDummy.setTaggedValue(OMITTED_KEY, omitted_values)

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

        self.assertEqual(
            'z3c.form.interfaces.IForm:hidden',
            field_node1.get(ns('mode', self.namespace))
        )
        self.assertEqual(
            'z3c.form.interfaces.IForm:true',
            field_node1.get(ns('omitted', self.namespace))
        )

        self.assertEqual(
            'z3c.form.interfaces.IForm:hidden '
            'z3c.form.interfaces.IEditForm:display',
            field_node2.get(ns('mode', self.namespace))
        )
        self.assertEqual(
            'z3c.form.interfaces.IForm:true '
            'z3c.form.interfaces.IEditForm:false',
            field_node2.get(ns('omitted', self.namespace))
        )
開發者ID:Martronic-SA,項目名稱:plone.autoform,代碼行數:46,代碼來源:test_supermodel_handler.py

示例8: test_write

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

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

        IDummy.setTaggedValue(WIDGETS_KEY, {'dummy': 'SomeWidget'})
        IDummy.setTaggedValue(OMITTED_KEY, [(Interface, 'dummy', 'true')])
        IDummy.setTaggedValue(MODES_KEY, [(Interface, 'dummy', 'hidden')])
        IDummy.setTaggedValue(ORDER_KEY, [('dummy', 'before', 'somefield',)])

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

        widget_node = field_node.find(ns('widget', self.namespace))
        self.assertEquals("SomeWidget", widget_node.get('type'))
        self.assertEquals("true", field_node.get(ns("omitted", self.namespace)))
        self.assertEquals("hidden", field_node.get(ns("mode", self.namespace)))
        self.assertEquals("somefield", field_node.get(ns("before", self.namespace)))
開發者ID:upiq,項目名稱:plone.autoform,代碼行數:21,代碼來源:test_supermodel_handler.py

示例9: test_write_partial

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

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

        IDummy.setTaggedValue(WIDGETS_KEY, {'dummy': 'SomeWidget'})
        IDummy.setTaggedValue(OMITTED_KEY, [(Interface, 'dummy2', 'true')])
        IDummy.setTaggedValue(
            MODES_KEY,
            [(Interface, 'dummy', 'display'), (Interface, 'dummy2', 'hidden')]
        )
        IDummy.setTaggedValue(ORDER_KEY, [])

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

        widget_node = field_node.find(ns('widget', self.namespace))
        self.assertEqual('SomeWidget', widget_node.get('type'))
        self.assertEqual(None, field_node.get(ns('omitted', self.namespace)))
        self.assertEqual('display', field_node.get(ns('mode', self.namespace)))
        self.assertEqual(None, field_node.get(ns('before', self.namespace)))
開發者ID:Martronic-SA,項目名稱:plone.autoform,代碼行數:24,代碼來源:test_supermodel_handler.py


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