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