Commit 04b49859 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.

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