Commit 6f3be039 authored by Ivan Tyagov's avatar Ivan Tyagov

Import order fixed. Catch and log errors accessing conversion server (this...

Import order fixed. Catch and log errors accessing conversion server (this prevents infinitive activity loops problem which make ZODB grow)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14271 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 34046a8f
...@@ -25,22 +25,14 @@ ...@@ -25,22 +25,14 @@
# #
############################################################################## ##############################################################################
import xmlrpclib import xmlrpclib, base64, re, zipfile, cStringIO, socket
from xmlrpclib import Fault
import base64
import re
import zipfile
import cStringIO
import socket
from warnings import warn from warnings import warn
from DateTime import DateTime from DateTime import DateTime
from xmlrpclib import Fault
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from OFS.Image import Pdata from OFS.Image import Pdata
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName, _setCacheHeaders
from Products.CMFCore.utils import _setCacheHeaders
from Products.DCWorkflow.DCWorkflow import ValidationFailed from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
from Products.ERP5Type.Cache import CachingMethod from Products.ERP5Type.Cache import CachingMethod
...@@ -48,8 +40,7 @@ from Products.ERP5Type.XMLObject import XMLObject ...@@ -48,8 +40,7 @@ from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.Document.File import File from Products.ERP5.Document.File import File
from Products.ERP5.Document.Document import ConversionCacheMixin, ConversionError from Products.ERP5.Document.Document import ConversionCacheMixin, ConversionError
from Products.ERP5.Document.File import _unpackData from Products.ERP5.Document.File import _unpackData
from zLOG import LOG, INFO, ERROR
from zLOG import LOG
enc=base64.encodestring enc=base64.encodestring
dec=base64.decodestring dec=base64.decodestring
...@@ -252,9 +243,15 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -252,9 +243,15 @@ class OOoDocument(File, ConversionCacheMixin):
z.close() z.close()
return 'text/plain', s return 'text/plain', s
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
try:
kw = server_proxy.run_generate(self.getId(), kw = server_proxy.run_generate(self.getId(),
enc(_unpackData(self.getBaseData())), enc(_unpackData(self.getBaseData())),
None, format) None,
format)
except Exception, inst:
# Catch, log and raise errors with converting server.Explicitly raise the exception!
LOG('[DMS]', ERROR, 'Error generating document %s' %inst)
raise Exception
return kw['mime'], Pdata(dec(kw['data'])) return kw['mime'], Pdata(dec(kw['data']))
# Conversion API # Conversion API
...@@ -361,10 +358,14 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -361,10 +358,14 @@ class OOoDocument(File, ConversionCacheMixin):
by invoking the conversion server. Store the result by invoking the conversion server. Store the result
on the object. Update metadata information. on the object. Update metadata information.
""" """
# LOG('in _convertToBaseFormat', 0, self.getRelativeUrl())
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
try:
kw = server_proxy.run_convert(self.getSourceReference() or self.getId(), kw = server_proxy.run_convert(self.getSourceReference() or self.getId(),
enc(_unpackData(self.getData()))) enc(_unpackData(self.getData())))
except Exception, inst:
# Catch, log and raise errors with converting server.Explicitly raise the exception!
LOG('[DMS]', ERROR, 'Error converting document to base format %s' %inst)
raise Exception
self._setBaseData(dec(kw['data'])) self._setBaseData(dec(kw['data']))
metadata = kw['meta'] metadata = kw['meta']
self._base_metadata = metadata self._base_metadata = metadata
...@@ -388,7 +389,12 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -388,7 +389,12 @@ class OOoDocument(File, ConversionCacheMixin):
through the invocation of the conversion server. through the invocation of the conversion server.
""" """
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
try:
kw = server_proxy.run_setmetadata(self.getId(), kw = server_proxy.run_setmetadata(self.getId(),
enc(_unpackData(self.getBaseData())), enc(_unpackData(self.getBaseData())),
kw) kw)
except Exception, inst:
# Catch, log and raise errors with converting server.Explicitly raise the exception!
LOG('[DMS]', ERROR, 'Error getting document\'s metadata %s' %inst)
raise Exception
self._setBaseData(dec(kw['data'])) self._setBaseData(dec(kw['data']))
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