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


Python DefaultAddForm.create方法代碼示例

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


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

示例1: test_form_create

# 需要導入模塊: from plone.dexterity.browser.add import DefaultAddForm [as 別名]
# 或者: from plone.dexterity.browser.add.DefaultAddForm import create [as 別名]
    def test_form_create(self):

        # Context and request
        context = Container(u"container")
        request = TestRequest()

        # FTI - returns dummy factory name

        fti_mock = DexterityFTI(u"testtype")
        fti_mock.factory = u'testfactory'
        self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")

        # The form we're testing
        form = DefaultAddForm(context, request)
        form.portal_type = u"testtype"

        class ISchema(Interface):
            foo = schema.TextLine()
        form.fields = Fields(ISchema)

        # createObject and applyChanges

        obj_dummy = Item(id="dummy")
        alsoProvides(obj_dummy, ISchema)
        data_dummy = {u"foo": u"bar"}

        from zope.component import createObject
        self.patch_global(createObject, return_value=obj_dummy)

        provideAdapter(AttributeField)

        self.assertEqual(obj_dummy, form.create(data_dummy))
        self.assertEqual("testtype", obj_dummy.portal_type)
開發者ID:plone,項目名稱:plone.dexterity,代碼行數:35,代碼來源:test_views.py

示例2: test_form_create

# 需要導入模塊: from plone.dexterity.browser.add import DefaultAddForm [as 別名]
# 或者: from plone.dexterity.browser.add.DefaultAddForm import create [as 別名]
 def test_form_create(self):
     
     # Context and request
     context = Container(u"container")
     request = TestRequest()
     
     # FTI - returns dummy factory name
     
     fti_mock = self.mocker.proxy(DexterityFTI(u"testtype"))
     self.expect(fti_mock.factory).result(u"testfactory")
     self.mock_utility(fti_mock, IDexterityFTI, name=u"testtype")
     
     # The form we're testing
     form = DefaultAddForm(context, request)
     form.portal_type = u"testtype"
     
     # createObject and applyChanges
     
     obj_dummy = Item(id="dummy")
     data_dummy = {u"foo": u"bar"}
     
     createObject_mock = self.mocker.replace('zope.component.createObject')
     self.expect(createObject_mock(u"testfactory")).result(obj_dummy)
     
     applyChanges_mock = self.mocker.replace('z3c.form.form.applyChanges')
     self.expect(applyChanges_mock(form, obj_dummy, data_dummy))
     
     self.replay()
     
     self.assertEquals(obj_dummy, form.create(data_dummy))
     self.assertEquals("testtype", obj_dummy.portal_type)
開發者ID:chaoflow,項目名稱:plone.dexterity,代碼行數:33,代碼來源:test_views.py

示例3: create

# 需要導入模塊: from plone.dexterity.browser.add import DefaultAddForm [as 別名]
# 或者: from plone.dexterity.browser.add.DefaultAddForm import create [as 別名]
 def create(self, data):
     def getAndRemoveKey(data, key, defaultValue):
         if key in data:
             value = data[key]
             del data[key]
             return value
         else:
             return defaultValue
             
     self.authors = getAndRemoveKey(data,'IAuthors.authors',[]) or []
     self.originalFile = dict(map(lambda key: (key, getAndRemoveKey(data,'IOriginalFile.' + key,None)),
                                  IOriginalFile.names()))
     self.submittedData = data
     self.submitAgain = self.request.get('REPEAT','N') == 'Y'
     created = DefaultAddForm.create(self,data)
     return created
開發者ID:edeposit,項目名稱:edeposit.content,代碼行數:18,代碼來源:epublication.py


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