Commit 9fcab36a authored by Nicolas Delaby's avatar Nicolas Delaby

Get rid of getToolByName

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41818 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dbc93412
...@@ -34,7 +34,6 @@ from Products.ERP5.Document.Document import Document, VALID_TEXT_FORMAT_LIST ...@@ -34,7 +34,6 @@ from Products.ERP5.Document.Document import Document, VALID_TEXT_FORMAT_LIST
from Products.ERP5.Document.Document import ConversionError from Products.ERP5.Document.Document import ConversionError
from Products.ERP5Type.Base import Base, removeIContentishInterface from Products.ERP5Type.Base import Base, removeIContentishInterface
from Products.CMFDefault.File import File as CMFFile from Products.CMFDefault.File import File as CMFFile
from Products.CMFCore.utils import getToolByName
from OFS.Image import Pdata from OFS.Image import Pdata
import cStringIO import cStringIO
from Products.ERP5Type.Utils import deprecated from Products.ERP5Type.Utils import deprecated
......
...@@ -52,7 +52,6 @@ from zLOG import LOG, WARNING ...@@ -52,7 +52,6 @@ from zLOG import LOG, WARNING
# import mixin # import mixin
from Products.ERP5.mixin.text_convertable import TextConvertableMixin from Products.ERP5.mixin.text_convertable import TextConvertableMixin
from Products.CMFCore.utils import getToolByName
def getDefaultImageQuality(portal, format=None): def getDefaultImageQuality(portal, format=None):
preference_tool = portal.portal_preferences preference_tool = portal.portal_preferences
...@@ -240,12 +239,12 @@ class Image(TextConvertableMixin, File, OFSImage): ...@@ -240,12 +239,12 @@ class Image(TextConvertableMixin, File, OFSImage):
""" """
Convert the image to text with portaltransforms Convert the image to text with portaltransforms
""" """
mime_type = getToolByName(self, 'mimetypes_registry').\ portal = self.getPortalObject()
lookupExtension('name.%s' % format) mime_type = portal.mimetypes_registry.lookupExtension('name.%s' % format)
mime_type = str(mime_type) mime_type = str(mime_type)
src_mimetype = self.getContentType() src_mimetype = self.getContentType()
content = self.getData() content = self.getData()
portal_transforms = getToolByName(self, 'portal_transforms') portal_transforms = portal.portal_transforms
result = portal_transforms.convertToData(mime_type, content, result = portal_transforms.convertToData(mime_type, content,
object=self, context=self, object=self, context=self,
filename=self.getTitleOrId(), filename=self.getTitleOrId(),
......
...@@ -29,8 +29,7 @@ ...@@ -29,8 +29,7 @@
import tempfile, os import tempfile, os
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import getToolByName, _setCacheHeaders,\ from Products.CMFCore.utils import _setCacheHeaders, _ViewEmulator
_ViewEmulator
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Image import Image from Products.ERP5.Document.Image import Image
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
from AccessControl.ZopeGuards import guarded_getattr from AccessControl.ZopeGuards import guarded_getattr
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.utils import _setCacheHeaders, _ViewEmulator from Products.CMFCore.utils import _setCacheHeaders, _ViewEmulator
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Document import Document, ConversionError, _MARKER, DEFAULT_CONTENT_TYPE from Products.ERP5.Document.Document import Document, ConversionError, _MARKER, DEFAULT_CONTENT_TYPE
...@@ -140,8 +139,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, ...@@ -140,8 +139,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin,
# can return document without conversion # can return document without conversion
return src_mimetype, self.getTextContent() return src_mimetype, self.getTextContent()
portal = self.getPortalObject() portal = self.getPortalObject()
mime_type = getToolByName(portal, 'mimetypes_registry').\ mime_type = portal.mimetypes_registry.lookupExtension('name.%s' % format)
lookupExtension('name.%s' % format)
original_mime_type = mime_type = str(mime_type) original_mime_type = mime_type = str(mime_type)
if text_content is None: if text_content is None:
# check if document has set text_content and convert if necessary # check if document has set text_content and convert if necessary
...@@ -153,7 +151,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, ...@@ -153,7 +151,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin,
if charset: if charset:
kw['charset'] = convert_kw['encoding'] = charset kw['charset'] = convert_kw['encoding'] = charset
if not self.hasConversion(**kw): if not self.hasConversion(**kw):
portal_transforms = getToolByName(portal, 'portal_transforms') portal_transforms = portal.portal_transforms
filename = self.getStandardFilename(format=format) filename = self.getStandardFilename(format=format)
if mime_type == 'text/html': if mime_type == 'text/html':
mime_type = 'text/x-html-safe' mime_type = 'text/x-html-safe'
......
...@@ -36,7 +36,6 @@ import string ...@@ -36,7 +36,6 @@ import string
from Acquisition import aq_base from Acquisition import aq_base
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.Cache import DEFAULT_CACHE_SCOPE from Products.ERP5Type.Cache import DEFAULT_CACHE_SCOPE
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from OFS.Image import Pdata, Image as OFSImage from OFS.Image import Pdata, Image as OFSImage
...@@ -79,8 +78,9 @@ class CachedConvertableMixin: ...@@ -79,8 +78,9 @@ class CachedConvertableMixin:
""" """
if self.getOriginalDocument() is None: if self.getOriginalDocument() is None:
return None return None
cache_tool = getToolByName(self, 'portal_caches') portal = self.getPortalObject()
preference_tool = getToolByName(self, 'portal_preferences') cache_tool = portal.portal_caches
preference_tool = portal.portal_preferences
cache_factory_name = preference_tool.getPreferredConversionCacheFactory('document_cache_factory') cache_factory_name = preference_tool.getPreferredConversionCacheFactory('document_cache_factory')
cache_factory = cache_tool.getRamCacheRoot().get(cache_factory_name) cache_factory = cache_tool.getRamCacheRoot().get(cache_factory_name)
#XXX This conditional statement should be remove as soon as #XXX This conditional statement should be remove as soon as
......
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