Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
138
Merge Requests
138
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
f5c8c656
Commit
f5c8c656
authored
Apr 30, 2024
by
Jérome Perrin
Committed by
Arnaud Fontaine
Jul 11, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OOoDocument: explicitly close connections to cloudooo
parent
a3b32345
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
11 deletions
+27
-11
bt5/erp5_base/DocumentTemplateItem/portal_components/document.erp5.OOoDocument.py
...mplateItem/portal_components/document.erp5.OOoDocument.py
+9
-7
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.Document.py
...tTemplateItem/portal_components/document.erp5.Document.py
+18
-4
No files found.
bt5/erp5_base/DocumentTemplateItem/portal_components/document.erp5.OOoDocument.py
View file @
f5c8c656
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#
#
##############################################################################
##############################################################################
import
contextlib
import
re
,
zipfile
import
re
,
zipfile
from
io
import
BytesIO
from
io
import
BytesIO
from
warnings
import
warn
from
warnings
import
warn
...
@@ -178,7 +179,8 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
...
@@ -178,7 +179,8 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
warn('
Your
oood
version
is
too
old
,
using
old
method
'
warn('
Your
oood
version
is
too
old
,
using
old
method
'
'
getAllowedTargets
instead
of
getAllowedTargetList
',
'
getAllowedTargets
instead
of
getAllowedTargetList
',
DeprecationWarning)
DeprecationWarning)
finally:
server_proxy.close()
# tuple order is reversed to be compatible with ERP5 Form
# tuple order is reversed to be compatible with ERP5 Form
return [(y, x) for x, y in allowed]
return [(y, x) for x, y in allowed]
...
@@ -208,8 +210,8 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
...
@@ -208,8 +210,8 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
cs.close()
cs.close()
z.close()
z.close()
return '
text
/
plain
', s
return '
text
/
plain
', s
server_proxy = DocumentConversionServerProxy(self)
orig_format = self.getBaseContentType()
orig_format = self.getBaseContentType()
with contextlib.closing(DocumentConversionServerProxy(self)) as server_proxy:
generate_result = server_proxy.run_generate(self.getId(),
generate_result = server_proxy.run_generate(self.getId(),
bytes2str(enc(bytes(self.getBaseData()))),
bytes2str(enc(bytes(self.getBaseData()))),
None,
None,
...
@@ -382,7 +384,7 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
...
@@ -382,7 +384,7 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
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.
"""
"""
server_proxy
=
DocumentConversionServerProxy
(
self
)
with
contextlib
.
closing
(
DocumentConversionServerProxy
(
self
))
as
server_proxy
:
response_code
,
response_dict
,
response_message
=
server_proxy
.
run_convert
(
response_code
,
response_dict
,
response_message
=
server_proxy
.
run_convert
(
self
.
getFilename
()
or
self
.
getId
(),
self
.
getFilename
()
or
self
.
getId
(),
bytes2str
(
enc
(
bytes
(
self
.
getData
()))),
bytes2str
(
enc
(
bytes
(
self
.
getData
()))),
...
@@ -421,7 +423,7 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
...
@@ -421,7 +423,7 @@ class OOoDocument(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixi
# XXX please pass a meaningful description of error as argument
# XXX please pass a meaningful description of error as argument
raise
NotConvertedError
()
raise
NotConvertedError
()
server_proxy
=
DocumentConversionServerProxy
(
self
)
with
contextlib
.
closing
(
DocumentConversionServerProxy
(
self
))
as
server_proxy
:
response_code
,
response_dict
,
response_message
=
\
response_code
,
response_dict
,
response_message
=
\
server_proxy
.
run_setmetadata
(
self
.
getId
(),
server_proxy
.
run_setmetadata
(
self
.
getId
(),
bytes2str
(
enc
(
bytes
(
self
.
getBaseData
()))),
bytes2str
(
enc
(
bytes
(
self
.
getBaseData
()))),
...
...
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.Document.py
View file @
f5c8c656
...
@@ -27,8 +27,9 @@
...
@@ -27,8 +27,9 @@
#
#
##############################################################################
##############################################################################
import
logging
import
re
import
re
from
zLOG
import
LOG
,
WARNING
from
zLOG
import
LOG
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
Products.ERP5Type.Accessor.Constant
import
PropertyGetter
as
ConstantGetter
from
Products.ERP5Type.Accessor.Constant
import
PropertyGetter
as
ConstantGetter
...
@@ -102,6 +103,7 @@ class DocumentConversionServerProxy():
...
@@ -102,6 +103,7 @@ class DocumentConversionServerProxy():
"""
"""
def
__init__
(
self
,
context
):
def
__init__
(
self
,
context
):
self
.
_serverproxy_list
=
[]
self
.
_serverproxy_list
=
[]
self
.
_logger
=
logging
.
getLogger
(
__name__
)
preference_tool
=
getToolByName
(
context
,
'portal_preferences'
)
preference_tool
=
getToolByName
(
context
,
'portal_preferences'
)
self
.
_ooo_server_retry
=
(
self
.
_ooo_server_retry
=
(
preference_tool
.
getPreferredDocumentConversionServerRetry
()
or
preference_tool
.
getPreferredDocumentConversionServerRetry
()
or
...
@@ -113,9 +115,9 @@ class DocumentConversionServerProxy():
...
@@ -113,9 +115,9 @@ class DocumentConversionServerProxy():
if
not
(
address
and
port
):
if
not
(
address
and
port
):
raise
ConversionError
(
'OOoDocument: cannot proceed with conversion:'
raise
ConversionError
(
'OOoDocument: cannot proceed with conversion:'
' conversion server url is not defined in preferences'
)
' conversion server url is not defined in preferences'
)
self
.
_logger
.
warning
(
LOG
(
'Document'
,
WARNING
,
'PreferredOoodocServer{Address,PortNumber}'
+
\
'PreferredOoodocServer{Address,PortNumber} are DEPRECATED '
' are DEPRECATED please use PreferredDocumentServerUrl instead'
,
error
=
True
)
'please use PreferredDocumentServerUrl instead'
)
uri_list
=
[
'%s://%s:%s'
%
(
'http'
,
address
,
port
)]
uri_list
=
[
'%s://%s:%s'
%
(
'http'
,
address
,
port
)]
...
@@ -209,6 +211,18 @@ class DocumentConversionServerProxy():
...
@@ -209,6 +211,18 @@ class DocumentConversionServerProxy():
def
__getattr__
(
self
,
attr
):
def
__getattr__
(
self
,
attr
):
return
partial
(
self
.
_proxy_function
,
attr
)
return
partial
(
self
.
_proxy_function
,
attr
)
def
close
(
self
):
error_list
=
[]
for
server_addr
,
proxy
in
self
.
_serverproxy_list
:
try
:
proxy
.
__call__
(
'close'
)()
except
Exception
as
e
:
self
.
_logger
.
exception
(
'Error closing %s'
,
server_addr
)
error_list
.
append
(
e
)
for
e
in
error_list
:
raise
e
from
erp5.component.mixin.DocumentExtensibleTraversableMixin
import
DocumentExtensibleTraversableMixin
from
erp5.component.mixin.DocumentExtensibleTraversableMixin
import
DocumentExtensibleTraversableMixin
from
erp5.component.interface.IConvertable
import
IConvertable
from
erp5.component.interface.IConvertable
import
IConvertable
from
erp5.component.interface.ITextConvertable
import
ITextConvertable
from
erp5.component.interface.ITextConvertable
import
ITextConvertable
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment