Commit 26e3c68b authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Preparation of erp5_base migration from FS: Fix pylint...

ZODB Components: Preparation of erp5_base migration from FS: Fix pylint no-name-in-module on newTempXXX (04b49859).
parent 062d17ca
Pipeline #7508 failed with stage
in 0 seconds
...@@ -16,8 +16,8 @@ if exchange_line.getBasePrice() in (None, 0, 0.0): ...@@ -16,8 +16,8 @@ if exchange_line.getBasePrice() in (None, 0, 0.0):
# We have to looking for other currency exchanges lines # We have to looking for other currency exchanges lines
# Note: SupplyCell is the class of Currency Exchange Line portal type objects # Note: SupplyCell is the class of Currency Exchange Line portal type objects
# But in reality, anything should do. # But in reality, anything should do.
from Products.ERP5Type.Document import newTempSupplyCell as newTemp temp_object = context.getPortalObject().newContent(temp_object=True,
temp_object = newTemp(context.getPortalObject(),'temp_object') portal_type='Supply Cell', id='temp_object')
start_date = exchange_line.getStartDate() start_date = exchange_line.getStartDate()
temp_kw = {'category_list':['resource/%s' % exchange_line.getParentValue().getRelativeUrl(), temp_kw = {'category_list':['resource/%s' % exchange_line.getParentValue().getRelativeUrl(),
'price_currency/%s' % exchange_line.getPriceCurrency()], 'price_currency/%s' % exchange_line.getPriceCurrency()],
......
...@@ -26,11 +26,10 @@ if to_currency is not None: ...@@ -26,11 +26,10 @@ if to_currency is not None:
if start_date is None: if start_date is None:
from DateTime import DateTime from DateTime import DateTime
start_date = DateTime() start_date = DateTime()
from Products.ERP5Type.Document import newTempBase
# Note: SupplyCell is the class of Currency Exchange Line portal type objects # Note: SupplyCell is the class of Currency Exchange Line portal type objects
# But in reality, anything should do. # But in reality, anything should do.
from Products.ERP5Type.Document import newTempSupplyCell as newTemp temp_object = context.getPortalObject().newContent(temp_object=True,
temp_object = newTemp(context.getPortalObject(),'temp_object') portal_type='Supply Cell', id='temp_object')
temp_kw = {'category_list':['resource/%s' % from_currency, temp_kw = {'category_list':['resource/%s' % from_currency,
'price_currency/%s' % to_currency], 'price_currency/%s' % to_currency],
'start_date':start_date 'start_date':start_date
......
from Products.ERP5Type.Document import newTempFile
from Products.ERP5OOo.OOoUtils import OOoParser from Products.ERP5OOo.OOoUtils import OOoParser
import string import string
...@@ -16,8 +15,8 @@ def getSpreadsheet(file): ...@@ -16,8 +15,8 @@ def getSpreadsheet(file):
if not (content_type.startswith('application/vnd.sun.xml') if not (content_type.startswith('application/vnd.sun.xml')
or content_type.startswith('application/vnd.oasis.opendocument')): or content_type.startswith('application/vnd.oasis.opendocument')):
from Products.ERP5Type.Document import newTempOOoDocument tmp_ooo = context.newContent(temp_object=True, portal_type='OOo Document',
tmp_ooo = newTempOOoDocument(context, file.filename) id=file.filename)
tmp_ooo.edit(data=file.read(), content_type=content_type) tmp_ooo.edit(data=file.read(), content_type=content_type)
tmp_ooo.convertToBaseFormat() tmp_ooo.convertToBaseFormat()
ignored, import_file_content = tmp_ooo.convert('ods') ignored, import_file_content = tmp_ooo.convert('ods')
...@@ -51,7 +50,7 @@ if len(listbox) == 0: ...@@ -51,7 +50,7 @@ if len(listbox) == 0:
# Start a session and store the content of the file # Start a session and store the content of the file
session_id = context.browser_id_manager.getBrowserId(create=1) session_id = context.browser_id_manager.getBrowserId(create=1)
session = context.portal_sessions[session_id] 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) temp_file.edit(spreadsheet_mapping=spreadsheets)
#create a temporary file_name #create a temporary file_name
......
...@@ -290,9 +290,6 @@ def TestResult_sendEmailNotification(self, mail_to=None, mail_from=None, ...@@ -290,9 +290,6 @@ def TestResult_sendEmailNotification(self, mail_to=None, mail_from=None,
extend_attachment(tb.splitlines()) extend_attachment(tb.splitlines())
extend_attachment(tb_list[-1].split(END)[0].splitlines()) extend_attachment(tb_list[-1].split(END)[0].splitlines())
from Products.ERP5Type.Document import newTempUrl
send_mail = newTempUrl(self, '_').send
attachment_list = [] attachment_list = []
if traceback_attachment: if traceback_attachment:
if include_diff: if include_diff:
...@@ -318,6 +315,7 @@ def TestResult_sendEmailNotification(self, mail_to=None, mail_from=None, ...@@ -318,6 +315,7 @@ def TestResult_sendEmailNotification(self, mail_to=None, mail_from=None,
mime_type='text/plain', mime_type='text/plain',
content=content)) content=content))
send_mail = self.newContent(temp_object=True, portal_type='Url', id='_').send
  • @xiaowu.zhang @arnau

    It seems this was not tested. Since update, we have:

      Module erp5.component.extension.erp5_version.TestResults, line 318, in TestResult_sendEmailNotification
        send_mail = self.newContent(temp_object=True, portal_type='Url', id='_').send
      Module Products.ERP5Type.Core.Folder, line 242, in newContent
        raise ValueError('No such content type: %s' % portal_type)
    ValueError: No such content type: Url

    I don't know if anybody still rely on test results email notifications, maybe we should disable it instead of fixing ?

  • i added a Url portal type for workaround

  • I see, thanks.

    This code must be old, I think this was written before portal_notifications and never updated to use portal_notifications. We should probably ask others before doing, but I guess we can just drop all the email notification code for test results.

  • @xiaowu.zhang @jerome Considering that we already have an Url Document in erp5_base, maybe we should add the corresponding Portal Type as @xiaowu.zhang did for Nexedi ERP5?

  • I don't know, there's already the Link portal type using Url class, maybe it's enough.

    Another quick fix could also be to use a Link here.

    But all this code is a bit strange, when we think about it, what URLs has to do with sending emails ( method is deprecated and just a wrapper on portal_notifications. Also why do we have both Url and Link ?

Please register or sign in to reply
for mail_to in mail_to_list: for mail_to in mail_to_list:
send_mail(from_url=mail_from, send_mail(from_url=mail_from,
to_url=mail_to, to_url=mail_to,
......
...@@ -240,8 +240,7 @@ class File(Document, CMFFile): ...@@ -240,8 +240,7 @@ class File(Document, CMFFile):
content_type.startswith("image/"): content_type.startswith("image/"):
# The file should behave like it is an Image for convert # The file should behave like it is an Image for convert
# the content to target format. # the content to target format.
from Products.ERP5Type.Document import newTempImage return self.newContent(temp_object=True, portal_type='Image', id=self.getId(),
return newTempImage(self, self.getId(),
data=self.getData(), data=self.getData(),
content_type=content_type, content_type=content_type,
filename=self.getFilename())._convert(format, **kw) filename=self.getFilename())._convert(format, **kw)
......
...@@ -604,7 +604,6 @@ class PDFTypeInformation(ERP5TypeInformation): ...@@ -604,7 +604,6 @@ class PDFTypeInformation(ERP5TypeInformation):
""" """
Returns the background image for a given page Returns the background image for a given page
""" """
from Products.ERP5Type.Document import newTempImage
import_pdf_file = self.getDefaultPdfFormValue() import_pdf_file = self.getDefaultPdfFormValue()
#depend on preferences, best xlargeheight = 1131 #depend on preferences, best xlargeheight = 1131
mime, image_data = import_pdf_file.convert(format = 'jpg', mime, image_data = import_pdf_file.convert(format = 'jpg',
...@@ -614,7 +613,8 @@ class PDFTypeInformation(ERP5TypeInformation): ...@@ -614,7 +613,8 @@ class PDFTypeInformation(ERP5TypeInformation):
display = 'xlarge') display = 'xlarge')
if image_data is None: if image_data is None:
return 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) page_image.setData(image_data)
self.REQUEST.RESPONSE.setHeader('Content-Type', mime) self.REQUEST.RESPONSE.setHeader('Content-Type', mime)
return page_image return page_image
......
...@@ -280,9 +280,8 @@ class ExplanationCache: ...@@ -280,9 +280,8 @@ class ExplanationCache:
# asComposedDocument() and business_process.getParentValue() is not a # asComposedDocument() and business_process.getParentValue() is not a
# module where newContent() allows creation of Business Processes. # module where newContent() allows creation of Business Processes.
# XXX-JPS is this really OK with union business processes # XXX-JPS is this really OK with union business processes
from Products.ERP5Type.Document import newTempBusinessProcess new_business_process = self.explanation.newContent(temp_object=True,
new_business_process = newTempBusinessProcess( portal_type='Business Process', id='closure_business_process')
self.explanation, 'closure_business_process')
for i, x in enumerate(business_link_list): for i, x in enumerate(business_link_list):
id = 'closure_path_%s' % i id = 'closure_path_%s' % i
new_business_process._setOb(id, x.asContext(id=id)) new_business_process._setOb(id, x.asContext(id=id))
...@@ -302,8 +301,8 @@ class ExplanationCache: ...@@ -302,8 +301,8 @@ class ExplanationCache:
return new_business_process return new_business_process
# Build Union Business Process # Build Union Business Process
from Products.ERP5Type.Document import newTempBusinessProcess new_business_process = self.explanation.newContent(temp_object=True,
new_business_process = newTempBusinessProcess(self.explanation, 'union_business_process') portal_type='Business Process', id='union_business_process')
i = 0 i = 0
for business_link in self.getBusinessLinkValueList(): for business_link in self.getBusinessLinkValueList():
i += 1 i += 1
......
...@@ -273,9 +273,8 @@ class DomainTool(BaseTool): ...@@ -273,9 +273,8 @@ class DomainTool(BaseTool):
mapped_value = None mapped_value = None
else: else:
# Generate tempDeliveryCell # Generate tempDeliveryCell
from Products.ERP5Type.Document import newTempSupplyCell mapped_value = self.getPortalObject().newContent(temp_object=True,
mapped_value = newTempSupplyCell(self.getPortalObject(), portal_type='Supply Cell', id='new_mapped_value')
'new_mapped_value')
mapped_value_property_dict = {} mapped_value_property_dict = {}
# Look for each property the first predicate which defines the # Look for each property the first predicate which defines the
# property # property
...@@ -318,7 +317,6 @@ class DomainTool(BaseTool): ...@@ -318,7 +317,6 @@ class DomainTool(BaseTool):
if predicate_list is None: if predicate_list is None:
predicate_list = self.searchPredicateList(context, test=test, **kw) predicate_list = self.searchPredicateList(context, test=test, **kw)
if predicate_list: if predicate_list:
from Products.ERP5Type.Document import newTempSupplyCell
mapped_value_property_dict = defaultdict(list) mapped_value_property_dict = defaultdict(list)
# Look for each property the first predicate with unique criterion # Look for each property the first predicate with unique criterion
# categories which defines the property # categories which defines the property
...@@ -327,8 +325,8 @@ class DomainTool(BaseTool): ...@@ -327,8 +325,8 @@ class DomainTool(BaseTool):
value = predicate.getProperty(mapped_value_property) value = predicate.getProperty(mapped_value_property)
if value is not None: if value is not None:
mapped_value_property_dict[mapped_value_property].append(value) mapped_value_property_dict[mapped_value_property].append(value)
mapped_value = newTempSupplyCell(self.getPortalObject(), mapped_value = self.getPortalObject().newContent(temp_object=True,
'multivalued_mapped_value') portal_type='Supply Cell', id='multivalued_mapped_value')
mapped_value._setMappedValuePropertyList( mapped_value._setMappedValuePropertyList(
mapped_value_property_dict.keys()) mapped_value_property_dict.keys())
mapped_value.__dict__.update(mapped_value_property_dict) mapped_value.__dict__.update(mapped_value_property_dict)
......
...@@ -597,8 +597,8 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -597,8 +597,8 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
Create a temp object_instance which will be tested. Create a temp object_instance which will be tested.
""" """
portal = self.getPortal() portal = self.getPortal()
from Products.ERP5Type.Document import newTempOrganisation tmp_object = portal.newContent(temp_object=True,
tmp_object = newTempOrganisation(portal, "a_wonderful_id") portal_type='Organisation', id="a_wonderful_id")
sequence.edit( sequence.edit(
object_instance=tmp_object, object_instance=tmp_object,
current_title='', current_title='',
...@@ -635,8 +635,8 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -635,8 +635,8 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
Create a temp object_instance which will be tested. Create a temp object_instance which will be tested.
""" """
portal = self.getPortal() portal = self.getPortal()
from Products.ERP5Type.Document import newTempAmount tmp_object = portal.newContent(temp_object=True, portal_type='Amount',
tmp_object = newTempAmount(portal, "another_wonderful_id") id="another_wonderful_id")
sequence.edit( sequence.edit(
object_instance=tmp_object, object_instance=tmp_object,
current_title='', current_title='',
...@@ -913,8 +913,8 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -913,8 +913,8 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
est to edit a temp object. est to edit a temp object.
""" """
portal = self.getPortal() portal = self.getPortal()
from Products.ERP5Type.Document import newTempOrganisation tmp_object = portal.newContent(temp_object=True, portal_type='Organisation',
tmp_object = newTempOrganisation(portal, "a_wonderful_id") id="a_wonderful_id")
tmp_object.edit(title='new title') tmp_object.edit(title='new title')
self.assertEqual('new title', tmp_object.getTitle()) self.assertEqual('new title', tmp_object.getTitle())
......
...@@ -914,11 +914,11 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -914,11 +914,11 @@ class TestERP5Base(ERP5TypeTestCase):
self.assertEqual('image/png', image.getContentType()) self.assertEqual('image/png', image.getContentType())
self.assertEqual((320, 250), (image.getWidth(), image.getHeight())) self.assertEqual((320, 250), (image.getWidth(), image.getHeight()))
from Products.ERP5Type.Document import newTempImage
def convert(**kw): def convert(**kw):
image_type, image_data = image.convert('jpg', display='thumbnail', **kw) image_type, image_data = image.convert('jpg', display='thumbnail', **kw)
self.assertEqual('image/jpeg', image_type) 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(image_type, thumbnail.getContentType())
self.assertEqual((128, 100), (thumbnail.getWidth(), self.assertEqual((128, 100), (thumbnail.getWidth(),
thumbnail.getHeight())) thumbnail.getHeight()))
......
...@@ -136,18 +136,16 @@ class PDFParser: ...@@ -136,18 +136,16 @@ class PDFParser:
security.declarePublic('getPageImage') security.declarePublic('getPageImage')
def getPageImage(self, page, format, resolution, quality): def getPageImage(self, page, format, resolution, quality):
""" """
Return an instance of newTempImage containing the pape page of Return a temporary Image object containing the pape page of the pdf file
the pdf file
width, height: attributes in pixel (px) width, height: attributes in pixel (px)
format: jpg, png, etc... format: jpg, png, etc...
resolution: resolution of produced image for exemple 600 resolution: resolution of produced image for exemple 600
quality: quality of produced image for exemple 200 raisonable quality quality: quality of produced image for exemple 200 raisonable quality
more hight is quality more time it takes to be gererated 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_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()) temp_pdf_document.setData(self.getData())
display = 'xlarge' display = 'xlarge'
mime, image_data = temp_pdf_document.convert(format = format, mime, image_data = temp_pdf_document.convert(format = format,
...@@ -157,7 +155,8 @@ class PDFParser: ...@@ -157,7 +155,8 @@ class PDFParser:
display = display) display = display)
page_image = None page_image = None
if image_data is not 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) page_image.setData(page_image)
return page_image return page_image
......
...@@ -303,8 +303,8 @@ class FormPrintout(Implicit, Persistent, RoleManager, Item, PropertyManager): ...@@ -303,8 +303,8 @@ class FormPrintout(Implicit, Persistent, RoleManager, Item, PropertyManager):
'inline;filename="%s%s"' % \ 'inline;filename="%s%s"' % \
(filename, guess_extension(content_type) or '')) (filename, guess_extension(content_type) or ''))
return printout return printout
from Products.ERP5Type.Document import newTempOOoDocument tmp_ooo = self.newContent(temp_object=True, portal_type='OOo Document',
tmp_ooo = newTempOOoDocument(self, self.title_or_id()) id=self.title_or_id())
tmp_ooo.edit(data=printout, tmp_ooo.edit(data=printout,
base_data=printout, base_data=printout,
filename=self.title_or_id(), filename=self.title_or_id(),
......
...@@ -54,7 +54,6 @@ except ImportError: ...@@ -54,7 +54,6 @@ except ImportError:
SUPPORTS_WEBDAV_LOCKS = 0 SUPPORTS_WEBDAV_LOCKS = 0
from Products.ERP5.Document.Document import ConversionError from Products.ERP5.Document.Document import ConversionError
import Products.ERP5Type.Document
from lxml import etree from lxml import etree
from lxml.etree import Element from lxml.etree import Element
...@@ -347,7 +346,7 @@ class OOoTemplate(ZopePageTemplate): ...@@ -347,7 +346,7 @@ class OOoTemplate(ZopePageTemplate):
# If this is not a File, build a new file with this content # If this is not a File, build a new file with this content
if not isinstance(picture, File): 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()) tmp_picture.setData(picture())
picture = tmp_picture picture = tmp_picture
...@@ -557,8 +556,8 @@ class OOoTemplate(ZopePageTemplate): ...@@ -557,8 +556,8 @@ class OOoTemplate(ZopePageTemplate):
else: else:
filename = self._getFileName() filename = self._getFileName()
from Products.ERP5Type.Document import newTempOOoDocument tmp_ooo = self.newContent(temp_object=True, portal_type='OOo Document',
tmp_ooo = newTempOOoDocument(self, self.title_or_id()) id=self.title_or_id())
tmp_ooo.edit(data=ooo, tmp_ooo.edit(data=ooo,
filename=filename, filename=filename,
content_type=mimetype,) content_type=mimetype,)
......
...@@ -589,8 +589,7 @@ class TestDocument(TestDocumentMixin): ...@@ -589,8 +589,7 @@ class TestDocument(TestDocumentMixin):
def testTempOOoDocument_get_size(self): def testTempOOoDocument_get_size(self):
# test get_size on temporary OOoDocument # test get_size on temporary OOoDocument
from Products.ERP5Type.Document import newTempOOoDocument doc = self.portal.newContent(temp_object=True, portal_type='OOo Document', id='tmp')
doc = newTempOOoDocument(self.portal, 'tmp')
doc.edit(data='OOo') doc.edit(data='OOo')
self.assertEqual(len('OOo'), doc.get_size()) self.assertEqual(len('OOo'), doc.get_size())
...@@ -603,8 +602,7 @@ class TestDocument(TestDocumentMixin): ...@@ -603,8 +602,7 @@ class TestDocument(TestDocumentMixin):
def testTempOOoDocument_hasData(self): def testTempOOoDocument_hasData(self):
# test hasData on TempOOoDocument # test hasData on TempOOoDocument
from Products.ERP5Type.Document import newTempOOoDocument doc = self.portal.newContent(temp_object=True, portal_type='OOo Document', id='tmp')
doc = newTempOOoDocument(self.portal, 'tmp')
self.assertFalse(doc.hasData()) self.assertFalse(doc.hasData())
doc.edit(file=makeFileUpload('import_data_list.ods')) doc.edit(file=makeFileUpload('import_data_list.ods'))
self.assertTrue(doc.hasData()) self.assertTrue(doc.hasData())
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from Products.PortalTransforms.libtransforms.commandtransform import commandtransform from Products.PortalTransforms.libtransforms.commandtransform import commandtransform
from Products.PortalTransforms.interfaces import idatastream from Products.PortalTransforms.interfaces import idatastream
from Products.ERP5Type.Document import newTempOOoDocument
from Products.ERP5.Document.Document import ConversionError from Products.ERP5.Document.Document import ConversionError
from Acquisition import aq_base from Acquisition import aq_base
from zope.interface import implements from zope.interface import implements
......
...@@ -211,37 +211,6 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -211,37 +211,6 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
def test_03_NewTempObject(self): def test_03_NewTempObject(self):
portal = self.portal 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 # Test newContent with the temp_object parameter
o = portal.person_module.newContent(id=987, portal_type="Person", temp_object=1) o = portal.person_module.newContent(id=987, portal_type="Person", temp_object=1)
o.setTitle('bar') o.setTitle('bar')
...@@ -255,6 +224,14 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -255,6 +224,14 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.assertEqual(b.isTempObject(), 1) self.assertEqual(b.isTempObject(), 1)
self.assertEqual(b.getId(), str(2)) 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 # Test newContent with the temp_object parameter and without ID
o = portal.person_module.newContent(portal_type="Person", temp_object=1) o = portal.person_module.newContent(portal_type="Person", temp_object=1)
o.setTitle('bar') o.setTitle('bar')
...@@ -294,12 +271,6 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -294,12 +271,6 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
# check we can create temp object without specific roles/permissions # check we can create temp object without specific roles/permissions
self.logout() self.logout()
self.loginWithNoRole() 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 ## newContent
o = portal.organisation_module.newContent(portal_type='Organisation', o = portal.organisation_module.newContent(portal_type='Organisation',
temp_object=1) temp_object=1)
...@@ -1864,8 +1835,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1864,8 +1835,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
portal.portal_types.resetDynamicDocuments() portal.portal_types.resetDynamicDocuments()
# Create a new temporary person object. # Create a new temporary person object.
from Products.ERP5Type.Document import newTempPerson o = portal.newContent(temp_object=True, portal_type='Person', id='temp_person_1')
o = newTempPerson(portal, 'temp_person_1')
self.assertTrue(o.isTempObject()) self.assertTrue(o.isTempObject())
self.assertEqual(o.getOriginalDocument(), None) self.assertEqual(o.getOriginalDocument(), None)
...@@ -1906,7 +1876,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1906,7 +1876,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.assertEqual(o.getValidationState(), 'validated') self.assertEqual(o.getValidationState(), 'validated')
# Create a new temporary person object. # 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()) self.assertTrue(o.isTempObject())
# This should call methods generated for the persistent object. # This should call methods generated for the persistent object.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment