diff --git a/bt5/erp5_banking_core/WorkflowTemplateItem/portal_workflow/currency_exchange_line_workflow/scripts/checkSingleExchangeLine.py b/bt5/erp5_banking_core/WorkflowTemplateItem/portal_workflow/currency_exchange_line_workflow/scripts/checkSingleExchangeLine.py index 8ed06f23ed1e3ddbb3b00bf5f308ef11fb39f6e6..cb2eee867505dfb3a0d3e475e7bdbdd012ff35ac 100644 --- a/bt5/erp5_banking_core/WorkflowTemplateItem/portal_workflow/currency_exchange_line_workflow/scripts/checkSingleExchangeLine.py +++ b/bt5/erp5_banking_core/WorkflowTemplateItem/portal_workflow/currency_exchange_line_workflow/scripts/checkSingleExchangeLine.py @@ -16,8 +16,8 @@ if exchange_line.getBasePrice() in (None, 0, 0.0): # We have to looking for other currency exchanges lines # Note: SupplyCell is the class of Currency Exchange Line portal type objects # But in reality, anything should do. -from Products.ERP5Type.Document import newTempSupplyCell as newTemp -temp_object = newTemp(context.getPortalObject(),'temp_object') +temp_object = context.getPortalObject().newContent(temp_object=True, + portal_type='Supply Cell', id='temp_object') start_date = exchange_line.getStartDate() temp_kw = {'category_list':['resource/%s' % exchange_line.getParentValue().getRelativeUrl(), 'price_currency/%s' % exchange_line.getPriceCurrency()], diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchange_getExchangeRateList.py b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchange_getExchangeRateList.py index 1eaeac0dc732bb19f17fa8191b333566381423e5..f55a3b14615f01e41189549cedf7465f2b308640 100644 --- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchange_getExchangeRateList.py +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/CurrencyExchange_getExchangeRateList.py @@ -26,11 +26,10 @@ if to_currency is not None: if start_date is None: from DateTime import DateTime start_date = DateTime() - from Products.ERP5Type.Document import newTempBase # Note: SupplyCell is the class of Currency Exchange Line portal type objects # But in reality, anything should do. - from Products.ERP5Type.Document import newTempSupplyCell as newTemp - temp_object = newTemp(context.getPortalObject(),'temp_object') + temp_object = context.getPortalObject().newContent(temp_object=True, + portal_type='Supply Cell', id='temp_object') temp_kw = {'category_list':['resource/%s' % from_currency, 'price_currency/%s' % to_currency], 'start_date':start_date diff --git a/bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_importFile.py b/bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_importFile.py index 76906f8de237eb59e1edf58126dc0294b09db721..eaa58461230ac449e7a01390d6c776713a5f1589 100644 --- a/bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_importFile.py +++ b/bt5/erp5_ooo_import/SkinTemplateItem/portal_skins/erp5_ooo_import/Base_importFile.py @@ -1,4 +1,3 @@ -from Products.ERP5Type.Document import newTempFile from Products.ERP5OOo.OOoUtils import OOoParser import string @@ -16,8 +15,8 @@ def getSpreadsheet(file): if not (content_type.startswith('application/vnd.sun.xml') or content_type.startswith('application/vnd.oasis.opendocument')): - from Products.ERP5Type.Document import newTempOOoDocument - tmp_ooo = newTempOOoDocument(context, file.filename) + tmp_ooo = context.newContent(temp_object=True, portal_type='OOo Document', + id=file.filename) tmp_ooo.edit(data=file.read(), content_type=content_type) tmp_ooo.convertToBaseFormat() ignored, import_file_content = tmp_ooo.convert('ods') @@ -51,7 +50,7 @@ if len(listbox) == 0: # Start a session and store the content of the file session_id = context.browser_id_manager.getBrowserId(create=1) session = context.portal_sessions[session_id] - temp_file = newTempFile(context, session_id) + temp_file = context.newContent(temp_object=True, portal_type='File', id=session_id) temp_file.edit(spreadsheet_mapping=spreadsheets) #create a temporary file_name diff --git a/bt5/erp5_test_result/ExtensionTemplateItem/portal_components/extension.erp5.TestResults.py b/bt5/erp5_test_result/ExtensionTemplateItem/portal_components/extension.erp5.TestResults.py index 194c7cb32d689a0a69c27dc34ffe7fec7c64f05a..4b0d8ff3f9cf6207434ac5a730d07b5f3d7f4c5c 100644 --- a/bt5/erp5_test_result/ExtensionTemplateItem/portal_components/extension.erp5.TestResults.py +++ b/bt5/erp5_test_result/ExtensionTemplateItem/portal_components/extension.erp5.TestResults.py @@ -290,9 +290,6 @@ def TestResult_sendEmailNotification(self, mail_to=None, mail_from=None, extend_attachment(tb.splitlines()) extend_attachment(tb_list[-1].split(END)[0].splitlines()) - from Products.ERP5Type.Document import newTempUrl - send_mail = newTempUrl(self, '_').send - attachment_list = [] if traceback_attachment: if include_diff: @@ -318,6 +315,7 @@ def TestResult_sendEmailNotification(self, mail_to=None, mail_from=None, mime_type='text/plain', content=content)) + send_mail = self.newContent(temp_object=True, portal_type='Url', id='_').send for mail_to in mail_to_list: send_mail(from_url=mail_from, to_url=mail_to, diff --git a/product/ERP5/Document/File.py b/product/ERP5/Document/File.py index a8cb2b8605f6736bd303e21de0040caf690378c3..10cb3668d63f4de1f04888ae8b448a9a1ff9e14b 100644 --- a/product/ERP5/Document/File.py +++ b/product/ERP5/Document/File.py @@ -240,8 +240,7 @@ class File(Document, CMFFile): content_type.startswith("image/"): # The file should behave like it is an Image for convert # the content to target format. - from Products.ERP5Type.Document import newTempImage - return newTempImage(self, self.getId(), + return self.newContent(temp_object=True, portal_type='Image', id=self.getId(), data=self.getData(), content_type=content_type, filename=self.getFilename())._convert(format, **kw) diff --git a/product/ERP5/Document/PDFTypeInformation.py b/product/ERP5/Document/PDFTypeInformation.py index 1bfd3e3e52f31d2d1631907684061d8113a2ee86..5a0acac3d540eb6ff787b912c25e1a87b49f1974 100644 --- a/product/ERP5/Document/PDFTypeInformation.py +++ b/product/ERP5/Document/PDFTypeInformation.py @@ -604,7 +604,6 @@ class PDFTypeInformation(ERP5TypeInformation): """ Returns the background image for a given page """ - from Products.ERP5Type.Document import newTempImage import_pdf_file = self.getDefaultPdfFormValue() #depend on preferences, best xlargeheight = 1131 mime, image_data = import_pdf_file.convert(format = 'jpg', @@ -614,7 +613,8 @@ class PDFTypeInformation(ERP5TypeInformation): display = 'xlarge') if image_data is None: return - page_image = newTempImage(self, "page_%s" % page) + page_image = self.newContent(temp_object=True, portal_type='Image', + id="page_%s" % page) page_image.setData(image_data) self.REQUEST.RESPONSE.setHeader('Content-Type', mime) return page_image diff --git a/product/ERP5/ExplanationCache.py b/product/ERP5/ExplanationCache.py index 59ff22cd61135a1a6979bc6ca4b0693296980de7..715a71a8e9687994af826eeb308b4d0ece8267bd 100644 --- a/product/ERP5/ExplanationCache.py +++ b/product/ERP5/ExplanationCache.py @@ -280,9 +280,8 @@ class ExplanationCache: # asComposedDocument() and business_process.getParentValue() is not a # module where newContent() allows creation of Business Processes. # XXX-JPS is this really OK with union business processes - from Products.ERP5Type.Document import newTempBusinessProcess - new_business_process = newTempBusinessProcess( - self.explanation, 'closure_business_process') + new_business_process = self.explanation.newContent(temp_object=True, + portal_type='Business Process', id='closure_business_process') for i, x in enumerate(business_link_list): id = 'closure_path_%s' % i new_business_process._setOb(id, x.asContext(id=id)) @@ -302,8 +301,8 @@ class ExplanationCache: return new_business_process # Build Union Business Process - from Products.ERP5Type.Document import newTempBusinessProcess - new_business_process = newTempBusinessProcess(self.explanation, 'union_business_process') + new_business_process = self.explanation.newContent(temp_object=True, + portal_type='Business Process', id='union_business_process') i = 0 for business_link in self.getBusinessLinkValueList(): i += 1 diff --git a/product/ERP5/Tool/DomainTool.py b/product/ERP5/Tool/DomainTool.py index ef2c153d19379a895abe8e15a51dbb27c9e9c45b..84e5ed23d47b976b19828571ea386f68b6bf73b2 100644 --- a/product/ERP5/Tool/DomainTool.py +++ b/product/ERP5/Tool/DomainTool.py @@ -273,9 +273,8 @@ class DomainTool(BaseTool): mapped_value = None else: # Generate tempDeliveryCell - from Products.ERP5Type.Document import newTempSupplyCell - mapped_value = newTempSupplyCell(self.getPortalObject(), - 'new_mapped_value') + mapped_value = self.getPortalObject().newContent(temp_object=True, + portal_type='Supply Cell', id='new_mapped_value') mapped_value_property_dict = {} # Look for each property the first predicate which defines the # property @@ -318,7 +317,6 @@ class DomainTool(BaseTool): if predicate_list is None: predicate_list = self.searchPredicateList(context, test=test, **kw) if predicate_list: - from Products.ERP5Type.Document import newTempSupplyCell mapped_value_property_dict = defaultdict(list) # Look for each property the first predicate with unique criterion # categories which defines the property @@ -327,8 +325,8 @@ class DomainTool(BaseTool): value = predicate.getProperty(mapped_value_property) if value is not None: mapped_value_property_dict[mapped_value_property].append(value) - mapped_value = newTempSupplyCell(self.getPortalObject(), - 'multivalued_mapped_value') + mapped_value = self.getPortalObject().newContent(temp_object=True, + portal_type='Supply Cell', id='multivalued_mapped_value') mapped_value._setMappedValuePropertyList( mapped_value_property_dict.keys()) mapped_value.__dict__.update(mapped_value_property_dict) diff --git a/product/ERP5/tests/testBase.py b/product/ERP5/tests/testBase.py index afdd7ca9d3486f18ef5eccd42dc900827bc1d1a8..edd3be1b98b8cdb3c62404b208013d5d8e725b09 100644 --- a/product/ERP5/tests/testBase.py +++ b/product/ERP5/tests/testBase.py @@ -597,8 +597,8 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): Create a temp object_instance which will be tested. """ portal = self.getPortal() - from Products.ERP5Type.Document import newTempOrganisation - tmp_object = newTempOrganisation(portal, "a_wonderful_id") + tmp_object = portal.newContent(temp_object=True, + portal_type='Organisation', id="a_wonderful_id") sequence.edit( object_instance=tmp_object, current_title='', @@ -635,8 +635,8 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): Create a temp object_instance which will be tested. """ portal = self.getPortal() - from Products.ERP5Type.Document import newTempAmount - tmp_object = newTempAmount(portal, "another_wonderful_id") + tmp_object = portal.newContent(temp_object=True, portal_type='Amount', + id="another_wonderful_id") sequence.edit( object_instance=tmp_object, current_title='', @@ -913,8 +913,8 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): est to edit a temp object. """ portal = self.getPortal() - from Products.ERP5Type.Document import newTempOrganisation - tmp_object = newTempOrganisation(portal, "a_wonderful_id") + tmp_object = portal.newContent(temp_object=True, portal_type='Organisation', + id="a_wonderful_id") tmp_object.edit(title='new title') self.assertEqual('new title', tmp_object.getTitle()) diff --git a/product/ERP5/tests/testERP5Base.py b/product/ERP5/tests/testERP5Base.py index d16d3adcedaed7072cd9e9517420f40e6ee8465e..7f8a644a7548e5fd19dfedbc3fbb8d2f59fd026c 100644 --- a/product/ERP5/tests/testERP5Base.py +++ b/product/ERP5/tests/testERP5Base.py @@ -914,11 +914,11 @@ class TestERP5Base(ERP5TypeTestCase): self.assertEqual('image/png', image.getContentType()) self.assertEqual((320, 250), (image.getWidth(), image.getHeight())) - from Products.ERP5Type.Document import newTempImage def convert(**kw): image_type, image_data = image.convert('jpg', display='thumbnail', **kw) self.assertEqual('image/jpeg', image_type) - thumbnail = newTempImage(self.portal, 'thumbnail', data=image_data) + thumbnail = self.portal.newContent(temp_object=True, portal_type='Image', + id='thumbnail', data=image_data) self.assertEqual(image_type, thumbnail.getContentType()) self.assertEqual((128, 100), (thumbnail.getWidth(), thumbnail.getHeight())) diff --git a/product/ERP5Form/PDFParser.py b/product/ERP5Form/PDFParser.py index 058ac73a1a6e19209dcb22e3cec93b84a3f1304b..e9346876036b1e9fa34baf86ac00afc80ebfb3ff 100644 --- a/product/ERP5Form/PDFParser.py +++ b/product/ERP5Form/PDFParser.py @@ -136,18 +136,16 @@ class PDFParser: security.declarePublic('getPageImage') def getPageImage(self, page, format, resolution, quality): """ - Return an instance of newTempImage containing the pape page of - the pdf file + Return a temporary Image object containing the pape page of the pdf file width, height: attributes in pixel (px) format: jpg, png, etc... resolution: resolution of produced image for exemple 600 quality: quality of produced image for exemple 200 raisonable quality more hight is quality more time it takes to be gererated """ - from Products.ERP5Type.Document import newTempPDFDocument - from Products.ERP5Type.Document import newTempImage temp_pdf_document_name = "tmp%s.pdf" % str(random.random()).split('.')[-1] - temp_pdf_document = newTempPDFDocument(self, temp_pdf_document_name) + temp_pdf_document = self.newContent(temp_object=True, + portal_type='PDF Document', id=temp_pdf_document_name) temp_pdf_document.setData(self.getData()) display = 'xlarge' mime, image_data = temp_pdf_document.convert(format = format, @@ -157,7 +155,8 @@ class PDFParser: display = display) page_image = None if image_data is not None: - page_image = newTempImage(self, "page_%s" % page) + page_image = self.newContent(temp_object=True, portal_type='Image', + id="page_%s" % page) page_image.setData(page_image) return page_image diff --git a/product/ERP5OOo/FormPrintout.py b/product/ERP5OOo/FormPrintout.py index 0787778351e928528d6613f20c10d48c0107911b..3f32fb41a6fec3d59aae49e3ef48b666e7602cef 100644 --- a/product/ERP5OOo/FormPrintout.py +++ b/product/ERP5OOo/FormPrintout.py @@ -303,8 +303,8 @@ class FormPrintout(Implicit, Persistent, RoleManager, Item, PropertyManager): 'inline;filename="%s%s"' % \ (filename, guess_extension(content_type) or '')) return printout - from Products.ERP5Type.Document import newTempOOoDocument - tmp_ooo = newTempOOoDocument(self, self.title_or_id()) + tmp_ooo = self.newContent(temp_object=True, portal_type='OOo Document', + id=self.title_or_id()) tmp_ooo.edit(data=printout, base_data=printout, filename=self.title_or_id(), diff --git a/product/ERP5OOo/OOoTemplate.py b/product/ERP5OOo/OOoTemplate.py index 6d8645087f7feb6b9f83f9cf21c049c6cb0455de..bb2632487e67c91f00102b12aeba42d146c212b6 100644 --- a/product/ERP5OOo/OOoTemplate.py +++ b/product/ERP5OOo/OOoTemplate.py @@ -54,7 +54,6 @@ except ImportError: SUPPORTS_WEBDAV_LOCKS = 0 from Products.ERP5.Document.Document import ConversionError -import Products.ERP5Type.Document from lxml import etree from lxml.etree import Element @@ -347,7 +346,7 @@ class OOoTemplate(ZopePageTemplate): # If this is not a File, build a new file with this content if not isinstance(picture, File): - tmp_picture = Products.ERP5Type.Document.newTempImage(self, 'tmp') + tmp_picture = self.newContent(temp_object=True, portal_type='Image', id='tmp') tmp_picture.setData(picture()) picture = tmp_picture @@ -557,8 +556,8 @@ class OOoTemplate(ZopePageTemplate): else: filename = self._getFileName() - from Products.ERP5Type.Document import newTempOOoDocument - tmp_ooo = newTempOOoDocument(self, self.title_or_id()) + tmp_ooo = self.newContent(temp_object=True, portal_type='OOo Document', + id=self.title_or_id()) tmp_ooo.edit(data=ooo, filename=filename, content_type=mimetype,) diff --git a/product/ERP5OOo/tests/testDms.py b/product/ERP5OOo/tests/testDms.py index aeb94a62fdd0952edd7554fd9cd2a4b3a2c721df..14d9943b656f1ebccbfff5c9f0c6e77f0a3bfdca 100644 --- a/product/ERP5OOo/tests/testDms.py +++ b/product/ERP5OOo/tests/testDms.py @@ -589,8 +589,7 @@ class TestDocument(TestDocumentMixin): def testTempOOoDocument_get_size(self): # test get_size on temporary OOoDocument - from Products.ERP5Type.Document import newTempOOoDocument - doc = newTempOOoDocument(self.portal, 'tmp') + doc = self.portal.newContent(temp_object=True, portal_type='OOo Document', id='tmp') doc.edit(data='OOo') self.assertEqual(len('OOo'), doc.get_size()) @@ -603,8 +602,7 @@ class TestDocument(TestDocumentMixin): def testTempOOoDocument_hasData(self): # test hasData on TempOOoDocument - from Products.ERP5Type.Document import newTempOOoDocument - doc = newTempOOoDocument(self.portal, 'tmp') + doc = self.portal.newContent(temp_object=True, portal_type='OOo Document', id='tmp') self.assertFalse(doc.hasData()) doc.edit(file=makeFileUpload('import_data_list.ods')) self.assertTrue(doc.hasData()) diff --git a/product/ERP5OOo/transforms/oood_commandtransform.py b/product/ERP5OOo/transforms/oood_commandtransform.py index 06a4fb4d6720f9b92d7a4fab8c305760ede02b7f..5799b312b7714c66c5c2e5c42028344360635f44 100644 --- a/product/ERP5OOo/transforms/oood_commandtransform.py +++ b/product/ERP5OOo/transforms/oood_commandtransform.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from Products.PortalTransforms.libtransforms.commandtransform import commandtransform from Products.PortalTransforms.interfaces import idatastream -from Products.ERP5Type.Document import newTempOOoDocument from Products.ERP5.Document.Document import ConversionError from Acquisition import aq_base from zope.interface import implements diff --git a/product/ERP5Type/tests/testERP5Type.py b/product/ERP5Type/tests/testERP5Type.py index 0f114e11f021feab9fba3e0e85536d7c83a25a82..cd90e89249c7240cade7ea684c569b657b9848b5 100644 --- a/product/ERP5Type/tests/testERP5Type.py +++ b/product/ERP5Type/tests/testERP5Type.py @@ -211,37 +211,6 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): def test_03_NewTempObject(self): portal = self.portal - # WARNING: `newTemp<PortalType>(self, ID)` is deprecated in favor of - # `self.newContent(portal_type=<PortalType>, temp_object=True, id=ID)` - from Products.ERP5Type.Document import newTempPerson - o = newTempPerson(portal, 1.2) - o.setTitle('toto') - self.assertEqual(o.getTitle(), 'toto') - self.assertEqual(str(o.getId()), str(1.2)) - - from Products.ERP5Type.Document import newTempOrganisation - o = newTempOrganisation(portal, -123) - o.setTitle('toto') - self.assertEqual(o.getTitle(), 'toto') - self.assertEqual(str(o.getId()), str(-123)) - - # Try to edit with any property and then get it with getProperty - o = newTempOrganisation(portal,'a') - o.edit(tutu='toto') - self.assertEqual(o.getProperty('tutu'), 'toto') - - # Same thing with an integer - o = newTempOrganisation(portal,'b') - o.edit(tata=123) - self.assertEqual(o.getProperty('tata'), 123) - - # Make sure this is a Temp Object - self.assertEqual(o.isTempObject(), 1) - - # Create a subobject and make sure it is a Temp Object - a = o.newContent(portal_type = 'Telephone') - self.assertEqual(a.isTempObject(), 1) - # Test newContent with the temp_object parameter o = portal.person_module.newContent(id=987, portal_type="Person", temp_object=1) o.setTitle('bar') @@ -255,6 +224,14 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): self.assertEqual(b.isTempObject(), 1) self.assertEqual(b.getId(), str(2)) + # Try to edit with any property and then get it with getProperty + o.edit(tutu='toto') + self.assertEqual(o.getProperty('tutu'), 'toto') + + # Same thing with an integer + o.edit(tata=123) + self.assertEqual(o.getProperty('tata'), 123) + # Test newContent with the temp_object parameter and without ID o = portal.person_module.newContent(portal_type="Person", temp_object=1) o.setTitle('bar') @@ -294,12 +271,6 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): # check we can create temp object without specific roles/permissions self.logout() self.loginWithNoRole() - ## newTemp<PORTAL_TYPE> - o = newTempOrganisation(portal.organisation_module,'b') - self.assertEqual(o.isTempObject(), 1) - a = o.newContent(portal_type = 'Telephone') - self.assertEqual(a.isTempObject(), 1) - self.assertEqual(a, guarded_getattr(o, a.getId())) ## newContent o = portal.organisation_module.newContent(portal_type='Organisation', temp_object=1) @@ -1864,8 +1835,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): portal.portal_types.resetDynamicDocuments() # Create a new temporary person object. - from Products.ERP5Type.Document import newTempPerson - o = newTempPerson(portal, 'temp_person_1') + o = portal.newContent(temp_object=True, portal_type='Person', id='temp_person_1') self.assertTrue(o.isTempObject()) self.assertEqual(o.getOriginalDocument(), None) @@ -1906,7 +1876,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): self.assertEqual(o.getValidationState(), 'validated') # Create a new temporary person object. - o = newTempPerson(portal, 'temp_person_2') + o = portal.newContent(temp_object=True, portal_type='Person', id='temp_person_2') self.assertTrue(o.isTempObject()) # This should call methods generated for the persistent object.