Commit 59111200 authored by Jérome Perrin's avatar Jérome Perrin

*: stop using newTemp* constructors

These constructors are not recognized by pylint and now we have
no-name-in-module errors.

Because since introduction of portal types as classes there was this
idea of deprecating those in favor of using newContent(temp_object=True,
switch to this new syntax.

Since we still have to create documents in portal_trash, only change the
minimal to get coding style tests passing again.
parent dae8b101
Pipeline #7374 failed with stage
in 0 seconds
...@@ -4,7 +4,6 @@ from ZODB.POSException import ConflictError ...@@ -4,7 +4,6 @@ from ZODB.POSException import ConflictError
from zExceptions import ExceptionFormatter from zExceptions import ExceptionFormatter
from Products.CMFActivity.ActiveResult import ActiveResult from Products.CMFActivity.ActiveResult import ActiveResult
from Products.ERP5Type.Document import newTempOOoDocument
from zLOG import LOG, INFO from zLOG import LOG, INFO
def dumpWorkflowChain(self, ignore_default=False, def dumpWorkflowChain(self, ignore_default=False,
...@@ -148,7 +147,11 @@ def checkConversionToolAvailability(self): ...@@ -148,7 +147,11 @@ def checkConversionToolAvailability(self):
severity = 0 severity = 0
try: try:
temp_document = newTempOOoDocument(self, document_id, data=document_file.data, source_reference=document_id) temp_document = portal.portal_trash.newContent(
portal_type='OOo Document',
temp_object=True,
data=document_file.data,
source_reference=document_id)
temp_document.convertToBaseFormat() temp_document.convertToBaseFormat()
_, html_result = temp_document.convert(format='html') _, html_result = temp_document.convert(format='html')
except ConflictError: except ConflictError:
......
...@@ -33,7 +33,6 @@ from zLOG import LOG, DEBUG ...@@ -33,7 +33,6 @@ from zLOG import LOG, DEBUG
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.Document import newTempDocument
class PaypalService(XMLObject): class PaypalService(XMLObject):
...@@ -67,15 +66,16 @@ class PaypalService(XMLObject): ...@@ -67,15 +66,16 @@ class PaypalService(XMLObject):
"""See Payment Service Interface Documentation""" """See Payment Service Interface Documentation"""
page_template = kw.pop("page_template") page_template = kw.pop("page_template")
paypal_dict = kw.get("paypal_dict", {}) paypal_dict = kw.get("paypal_dict", {})
temp_document = newTempDocument(self, 'id') temp_document = self.getPortalObject().portal_trash.newContent(
temp_document.edit( portal_type='Document',
temp_object=True,
link_url_string=self.getLinkUrlString(), link_url_string=self.getLinkUrlString(),
title=self.getTitle(), title=self.getTitle(),
field_list=self._getFieldList(paypal_dict), field_list=self._getFieldList(paypal_dict),
# append the rest of transmitted parameters page template # append the rest of transmitted parameters page template
**kw **kw
) )
return getattr(temp_document, page_template)() return getattr(temp_document.__of__(self), page_template)()
def notifySuccess(self, redirect_path=None, REQUEST=None): def notifySuccess(self, redirect_path=None, REQUEST=None):
"""See Payment Service Interface Documentation""" """See Payment Service Interface Documentation"""
......
...@@ -30,6 +30,7 @@ from Products.ERP5OOo.OOoUtils import OOoParser ...@@ -30,6 +30,7 @@ from Products.ERP5OOo.OOoUtils import OOoParser
parser = OOoParser() parser = OOoParser()
category_list_spreadsheet_mapping = {} category_list_spreadsheet_mapping = {}
error_list = [] error_list = []
portal = context.getPortalObject()
def default_invalid_spreadsheet_error_handler(error_message): def default_invalid_spreadsheet_error_handler(error_message):
raise ValueError(error_message) raise ValueError(error_message)
...@@ -37,8 +38,8 @@ def default_invalid_spreadsheet_error_handler(error_message): ...@@ -37,8 +38,8 @@ def default_invalid_spreadsheet_error_handler(error_message):
if invalid_spreadsheet_error_handler is None: if invalid_spreadsheet_error_handler is None:
invalid_spreadsheet_error_handler = default_invalid_spreadsheet_error_handler invalid_spreadsheet_error_handler = default_invalid_spreadsheet_error_handler
property_id_set = context.portal_types.Category.getInstancePropertySet() property_id_set = portal.portal_types.Category.getInstancePropertySet()
property_id_set.update(getattr(context.portal_types, 'Base Category').getInstancePropertySet()) property_id_set.update(getattr(portal.portal_types, 'Base Category').getInstancePropertySet())
def getIDFromString(string=None): def getIDFromString(string=None):
""" """
...@@ -83,10 +84,11 @@ if hasattr(import_file, 'headers'): ...@@ -83,10 +84,11 @@ if hasattr(import_file, 'headers'):
content_type = import_file.headers.get('Content-Type', '') content_type = import_file.headers.get('Content-Type', '')
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 = portal.portal_trash.newContent(
tmp_ooo = newTempOOoDocument(context, "_") portal_type='OOo Document',
tmp_ooo.edit(data=import_file.read(), temp_object=True,
content_type=content_type) data=import_file.read(),
content_type=content_type)
tmp_ooo.convertToBaseFormat() tmp_ooo.convertToBaseFormat()
_, import_file_content = tmp_ooo.convert('ods') _, import_file_content = tmp_ooo.convert('ods')
parser.openFromString(str(import_file_content)) parser.openFromString(str(import_file_content))
......
'''Returns all possible document conversions from the `base_content_type`. '''Returns all possible document conversions from the `base_content_type`.
''' '''
from Products.ERP5Type.Document import newTempOOoDocument td = context.getPortalObject().portal_trash.newContent(
td = newTempOOoDocument(context, 'testOOo') portal_type='OOo Document',
td.edit(base_content_type=base_content_type, base_data='not empty') temp_object=True,
base_content_type=base_content_type,
base_data='not empty')
return [('', '')] + td.getTargetFormatItemList() return [('', '')] + td.getTargetFormatItemList()
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