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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
erp5
Commits
6015079d
Commit
6015079d
authored
Apr 25, 2022
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: 2to3: cStringIO.
parent
94e54af7
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
70 additions
and
72 deletions
+70
-72
bt5/erp5_access_token/TestTemplateItem/portal_components/test.erp5.testERP5AccessToken.py
...teItem/portal_components/test.erp5.testERP5AccessToken.py
+1
-1
bt5/erp5_authentication_policy/TestTemplateItem/portal_components/test.erp5.testAuthenticationPolicy.py
...m/portal_components/test.erp5.testAuthenticationPolicy.py
+4
-4
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testAutoLogout.py
...emplateItem/portal_components/test.erp5.testAutoLogout.py
+3
-3
product/CMFActivity/Activity/Queue.py
product/CMFActivity/Activity/Queue.py
+0
-1
product/DeadlockDebugger/dumper.py
product/DeadlockDebugger/dumper.py
+2
-2
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+12
-12
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+3
-3
product/ERP5/Tool/TrashTool.py
product/ERP5/Tool/TrashTool.py
+2
-2
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.TextDocument.py
...plateItem/portal_components/document.erp5.TextDocument.py
+1
-1
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.BaseConvertableFileMixin.py
.../portal_components/mixin.erp5.BaseConvertableFileMixin.py
+2
-2
product/ERP5/bootstrap/erp5_core/ModuleComponentTemplateItem/portal_components/module.erp5.WebDAVSupport.py
...mplateItem/portal_components/module.erp5.WebDAVSupport.py
+2
-2
product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.ContributionTool.py
...plateItem/portal_components/tool.erp5.ContributionTool.py
+2
-2
product/ERP5Form/PDFTemplate.py
product/ERP5Form/PDFTemplate.py
+4
-4
product/ERP5OOo/OOoTemplate.py
product/ERP5OOo/OOoTemplate.py
+2
-2
product/ERP5OOo/OOoUtils.py
product/ERP5OOo/OOoUtils.py
+5
-5
product/ERP5OOo/tests/TestFormPrintoutMixin.py
product/ERP5OOo/tests/TestFormPrintoutMixin.py
+2
-2
product/ERP5OOo/tests/testIngestion.py
product/ERP5OOo/tests/testIngestion.py
+1
-1
product/ERP5OOo/tests/testOOoDynamicStyle.py
product/ERP5OOo/tests/testOOoDynamicStyle.py
+2
-2
product/ERP5OOo/tests/utils.py
product/ERP5OOo/tests/utils.py
+3
-3
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+1
-2
product/ERP5Type/mixin/json_representable.py
product/ERP5Type/mixin/json_representable.py
+3
-3
product/ERP5Type/patches/OFSImage.py
product/ERP5Type/patches/OFSImage.py
+2
-2
product/ERP5Type/patches/urllib_opener.py
product/ERP5Type/patches/urllib_opener.py
+4
-4
product/ERP5Type/tests/ERP5TypeTestCase.py
product/ERP5Type/tests/ERP5TypeTestCase.py
+3
-3
product/ERP5Type/tests/Python3StyleTest.py
product/ERP5Type/tests/Python3StyleTest.py
+2
-2
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+2
-2
No files found.
bt5/erp5_access_token/TestTemplateItem/portal_components/test.erp5.testERP5AccessToken.py
View file @
6015079d
...
@@ -438,7 +438,7 @@ class TestERP5DumbHTTPExtractionPlugin(AccessTokenTestCase):
...
@@ -438,7 +438,7 @@ class TestERP5DumbHTTPExtractionPlugin(AccessTokenTestCase):
env
[
'GATEWAY_INTERFACE'
]
=
'CGI/1.1 '
env
[
'GATEWAY_INTERFACE'
]
=
'CGI/1.1 '
env
[
'SCRIPT_NAME'
]
=
'Main'
env
[
'SCRIPT_NAME'
]
=
'Main'
env
.
update
(
headers
)
env
.
update
(
headers
)
return
HTTPRequest
(
io
.
String
IO
(),
env
,
HTTPResponse
())
return
HTTPRequest
(
io
.
Bytes
IO
(),
env
,
HTTPResponse
())
def
test_working_authentication
(
self
):
def
test_working_authentication
(
self
):
request
=
self
.
do_fake_request
(
"GET"
,
{
"HTTP_AUTHORIZATION"
:
"Basic "
+
base64
.
b64encode
(
"login:password"
)})
request
=
self
.
do_fake_request
(
"GET"
,
{
"HTTP_AUTHORIZATION"
:
"Basic "
+
base64
.
b64encode
(
"login:password"
)})
...
...
bt5/erp5_authentication_policy/TestTemplateItem/portal_components/test.erp5.testAuthenticationPolicy.py
View file @
6015079d
...
@@ -32,7 +32,7 @@ from functools import partial
...
@@ -32,7 +32,7 @@ from functools import partial
import
unittest
import
unittest
import
urllib.request
,
urllib
.
parse
,
urllib
.
error
import
urllib.request
,
urllib
.
parse
,
urllib
.
error
import
urllib.parse
import
urllib.parse
from
io
import
String
IO
from
io
import
Bytes
IO
import
time
import
time
import
http.client
import
http.client
import
mock
import
mock
...
@@ -756,7 +756,7 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
...
@@ -756,7 +756,7 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
response
=
self
.
publish
(
response
=
self
.
publish
(
portal
.
absolute_url_path
()
+
'/logged_in'
,
portal
.
absolute_url_path
()
+
'/logged_in'
,
basic
=
'test-05:used_ALREADY_1234'
,
basic
=
'test-05:used_ALREADY_1234'
,
stdin
=
String
IO
(
urllib
.
parse
.
urlencode
({
'came_from'
:
'https://www.erp5.com'
})),
stdin
=
Bytes
IO
(
urllib
.
parse
.
urlencode
({
'came_from'
:
'https://www.erp5.com'
})),
request_method
=
'POST'
,
request_method
=
'POST'
,
)
)
redirect_url
=
urllib
.
parse
.
urlparse
(
response
.
getHeader
(
"Location"
))
redirect_url
=
urllib
.
parse
.
urlparse
(
response
.
getHeader
(
"Location"
))
...
@@ -819,7 +819,7 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
...
@@ -819,7 +819,7 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
def
submit_reset_password_dialog
(
new_password
):
def
submit_reset_password_dialog
(
new_password
):
return
self
.
publish
(
return
self
.
publish
(
'%s/portal_password'
%
self
.
portal
.
getPath
(),
'%s/portal_password'
%
self
.
portal
.
getPath
(),
stdin
=
String
IO
(
urllib
.
parse
.
urlencode
({
stdin
=
Bytes
IO
(
urllib
.
parse
.
urlencode
({
'Base_callDialogMethod:method'
:
''
,
'Base_callDialogMethod:method'
:
''
,
'dialog_id'
:
'PasswordTool_viewResetPassword'
,
'dialog_id'
:
'PasswordTool_viewResetPassword'
,
'dialog_method'
:
'PasswordTool_changeUserPassword'
,
'dialog_method'
:
'PasswordTool_changeUserPassword'
,
...
@@ -874,7 +874,7 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
...
@@ -874,7 +874,7 @@ class TestAuthenticationPolicy(ERP5TypeTestCase):
return
self
.
publish
(
return
self
.
publish
(
'%s/portal_preferences'
%
self
.
portal
.
getPath
(),
'%s/portal_preferences'
%
self
.
portal
.
getPath
(),
basic
=
'%s:current'
%
self
.
id
(),
basic
=
'%s:current'
%
self
.
id
(),
stdin
=
String
IO
(
urllib
.
parse
.
urlencode
({
stdin
=
Bytes
IO
(
urllib
.
parse
.
urlencode
({
'Base_callDialogMethod:method'
:
''
,
'Base_callDialogMethod:method'
:
''
,
'dialog_id'
:
'PreferenceTool_viewChangePasswordDialog'
,
'dialog_id'
:
'PreferenceTool_viewChangePasswordDialog'
,
'dialog_method'
:
'PreferenceTool_setNewPassword'
,
'dialog_method'
:
'PreferenceTool_setNewPassword'
,
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testAutoLogout.py
View file @
6015079d
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
##############################################################################
##############################################################################
from
functools
import
partial
from
functools
import
partial
from
io
import
String
IO
from
io
import
Bytes
IO
import
unittest
import
unittest
import
urllib.request
,
urllib
.
parse
,
urllib
.
error
import
urllib.request
,
urllib
.
parse
,
urllib
.
error
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
...
@@ -81,7 +81,7 @@ class TestAuoLogout(ERP5TypeTestCase):
...
@@ -81,7 +81,7 @@ class TestAuoLogout(ERP5TypeTestCase):
portal
.
absolute_url_path
()
+
'/view'
,
portal
.
absolute_url_path
()
+
'/view'
,
request_method
=
'POST'
,
request_method
=
'POST'
,
)
)
response
=
publish
(
stdin
=
String
IO
(
stdin
))
response
=
publish
(
stdin
=
Bytes
IO
(
stdin
))
self
.
assertIn
(
'Welcome to ERP5'
,
response
.
getBody
())
self
.
assertIn
(
'Welcome to ERP5'
,
response
.
getBody
())
# check '__ac' cookie has set an expire timeout
# check '__ac' cookie has set an expire timeout
...
@@ -96,7 +96,7 @@ class TestAuoLogout(ERP5TypeTestCase):
...
@@ -96,7 +96,7 @@ class TestAuoLogout(ERP5TypeTestCase):
self
.
tic
()
self
.
tic
()
portal
.
portal_caches
.
clearAllCache
()
portal
.
portal_caches
.
clearAllCache
()
response
=
publish
(
stdin
=
String
IO
(
stdin
))
response
=
publish
(
stdin
=
Bytes
IO
(
stdin
))
self
.
assertIn
(
'Welcome to ERP5'
,
response
.
getBody
())
self
.
assertIn
(
'Welcome to ERP5'
,
response
.
getBody
())
ac_cookie
=
response
.
getCookie
(
'__ac'
)
ac_cookie
=
response
.
getCookie
(
'__ac'
)
self
.
assertNotEqual
(
ac_cookie
,
None
)
self
.
assertNotEqual
(
ac_cookie
,
None
)
...
...
product/CMFActivity/Activity/Queue.py
View file @
6015079d
...
@@ -31,7 +31,6 @@ from hashlib import sha1
...
@@ -31,7 +31,6 @@ from hashlib import sha1
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
zLOG
import
LOG
,
WARNING
,
ERROR
from
zLOG
import
LOG
,
WARNING
,
ERROR
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
from
io
import
BytesIO
as
StringIO
# Time global parameters
# Time global parameters
MAX_PROCESSING_TIME
=
900
# in seconds
MAX_PROCESSING_TIME
=
900
# in seconds
...
...
product/DeadlockDebugger/dumper.py
View file @
6015079d
...
@@ -27,7 +27,7 @@ import _thread
...
@@ -27,7 +27,7 @@ import _thread
from
sys
import
_current_frames
from
sys
import
_current_frames
import
traceback
import
traceback
import
time
import
time
from
io
import
BytesIO
as
StringIO
from
io
import
BytesIO
from
zLOG
import
LOG
,
DEBUG
,
ERROR
from
zLOG
import
LOG
,
DEBUG
,
ERROR
from
App.config
import
getConfiguration
from
App.config
import
getConfiguration
...
@@ -76,7 +76,7 @@ def dump_threads():
...
@@ -76,7 +76,7 @@ def dump_threads():
except
ImportError
:
except
ImportError
:
pass
pass
output
=
String
IO
()
output
=
Bytes
IO
()
traceback
.
print_stack
(
frame
,
file
=
output
)
traceback
.
print_stack
(
frame
,
file
=
output
)
res
.
append
(
"Thread %s%s:
\
n
%s%s"
%
res
.
append
(
"Thread %s%s:
\
n
%s%s"
%
(
thread_id
,
reqinfo
,
output
.
getvalue
(),
mysql_info
))
(
thread_id
,
reqinfo
,
output
.
getvalue
(),
mysql_info
))
...
...
product/ERP5/Document/BusinessTemplate.py
View file @
6015079d
...
@@ -75,7 +75,7 @@ from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
...
@@ -75,7 +75,7 @@ from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from
OFS.Traversable
import
NotFound
from
OFS.Traversable
import
NotFound
from
OFS
import
SimpleItem
from
OFS
import
SimpleItem
from
OFS.Image
import
Pdata
from
OFS.Image
import
Pdata
from
io
import
BytesIO
as
StringIO
from
io
import
BytesIO
from
copy
import
deepcopy
from
copy
import
deepcopy
from
zExceptions
import
BadRequest
from
zExceptions
import
BadRequest
from
Products.ERP5Type.XMLExportImport
import
exportXML
from
Products.ERP5Type.XMLExportImport
import
exportXML
...
@@ -355,7 +355,7 @@ class BusinessTemplateArchive(object):
...
@@ -355,7 +355,7 @@ class BusinessTemplateArchive(object):
else
:
else
:
if
isinstance
(
obj
,
str
):
if
isinstance
(
obj
,
str
):
self
.
revision
.
hash
(
path
,
obj
)
self
.
revision
.
hash
(
path
,
obj
)
obj
=
String
IO
(
obj
)
obj
=
Bytes
IO
(
obj
)
else
:
else
:
obj
.
seek
(
0
)
obj
.
seek
(
0
)
self
.
revision
.
hash
(
path
,
obj
.
read
())
self
.
revision
.
hash
(
path
,
obj
.
read
())
...
@@ -420,7 +420,7 @@ class BusinessTemplateTarball(BusinessTemplateArchive):
...
@@ -420,7 +420,7 @@ class BusinessTemplateTarball(BusinessTemplateArchive):
def
__init__
(
self
,
path
,
creation
=
0
,
importing
=
0
,
**
kw
):
def
__init__
(
self
,
path
,
creation
=
0
,
importing
=
0
,
**
kw
):
super
(
BusinessTemplateTarball
,
self
).
__init__
(
path
,
**
kw
)
super
(
BusinessTemplateTarball
,
self
).
__init__
(
path
,
**
kw
)
if
creation
:
if
creation
:
self
.
fobj
=
String
IO
()
self
.
fobj
=
Bytes
IO
()
self
.
tar
=
tarfile
.
open
(
''
,
'w:gz'
,
self
.
fobj
)
self
.
tar
=
tarfile
.
open
(
''
,
'w:gz'
,
self
.
fobj
)
self
.
time
=
time
.
time
()
self
.
time
=
time
.
time
()
elif
importing
:
elif
importing
:
...
@@ -849,7 +849,7 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -849,7 +849,7 @@ class ObjectTemplateItem(BaseTemplateItem):
if
not
extension
:
if
not
extension
:
extension
=
self
.
guessExtensionOfDocument
(
obj
,
key
,
extension
=
self
.
guessExtensionOfDocument
(
obj
,
key
,
data
if
record_id
==
'data'
else
None
)
data
if
record_id
==
'data'
else
None
)
bta
.
addObject
(
String
IO
(
data
),
key
,
path
=
path
,
bta
.
addObject
(
Bytes
IO
(
data
),
key
,
path
=
path
,
ext
=
'._xml'
if
extension
==
'xml'
else
'.'
+
extension
)
ext
=
'._xml'
if
extension
==
'xml'
else
'.'
+
extension
)
break
break
# since we get the obj from context we should
# since we get the obj from context we should
...
@@ -857,7 +857,7 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -857,7 +857,7 @@ class ObjectTemplateItem(BaseTemplateItem):
obj
=
self
.
removeProperties
(
obj
,
1
,
keep_workflow_history
=
True
)
obj
=
self
.
removeProperties
(
obj
,
1
,
keep_workflow_history
=
True
)
transaction
.
savepoint
(
optimistic
=
True
)
transaction
.
savepoint
(
optimistic
=
True
)
f
=
String
IO
()
f
=
Bytes
IO
()
exportXML
(
obj
.
_p_jar
,
obj
.
_p_oid
,
f
)
exportXML
(
obj
.
_p_jar
,
obj
.
_p_oid
,
f
)
bta
.
addObject
(
f
,
key
,
path
=
path
)
bta
.
addObject
(
f
,
key
,
path
=
path
)
...
@@ -1010,7 +1010,7 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -1010,7 +1010,7 @@ class ObjectTemplateItem(BaseTemplateItem):
key
=
'%s:%s'
%
(
name
,
mtime
)
key
=
'%s:%s'
%
(
name
,
mtime
)
try
:
try
:
return
String
IO
(
cache_database
.
db
[
key
])
return
Bytes
IO
(
cache_database
.
db
[
key
])
except
:
except
:
pass
pass
...
@@ -1018,7 +1018,7 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -1018,7 +1018,7 @@ class ObjectTemplateItem(BaseTemplateItem):
from
Products.ERP5Type.XMLExportImport
import
(
ppml
,
from
Products.ERP5Type.XMLExportImport
import
(
ppml
,
start_zopedata
,
save_record
,
save_zopedata
)
start_zopedata
,
save_record
,
save_zopedata
)
import
xml.parsers.expat
import
xml.parsers.expat
outfile
=
String
IO
()
outfile
=
Bytes
IO
()
try
:
try
:
data
=
file
.
read
()
data
=
file
.
read
()
F
=
ppml
.
xmlPickler
()
F
=
ppml
.
xmlPickler
()
...
@@ -1067,8 +1067,8 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -1067,8 +1067,8 @@ class ObjectTemplateItem(BaseTemplateItem):
for
path
,
old_object
in
upgrade_list
:
for
path
,
old_object
in
upgrade_list
:
# compare object to see it there is changes
# compare object to see it there is changes
new_object
=
self
.
_objects
[
path
]
new_object
=
self
.
_objects
[
path
]
new_io
=
String
IO
()
new_io
=
Bytes
IO
()
old_io
=
String
IO
()
old_io
=
Bytes
IO
()
exportXML
(
new_object
.
_p_jar
,
new_object
.
_p_oid
,
new_io
)
exportXML
(
new_object
.
_p_jar
,
new_object
.
_p_oid
,
new_io
)
new_obj_xml
=
new_io
.
getvalue
()
new_obj_xml
=
new_io
.
getvalue
()
try
:
try
:
...
@@ -1107,7 +1107,7 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -1107,7 +1107,7 @@ class ObjectTemplateItem(BaseTemplateItem):
for
subobject_id
in
obj
.
objectIds
():
for
subobject_id
in
obj
.
objectIds
():
subobject
=
obj
[
subobject_id
]
subobject
=
obj
[
subobject_id
]
subobject_dict
[
subobject_id
]
=
subobject
.
_p_jar
.
exportFile
(
subobject_dict
[
subobject_id
]
=
subobject
.
_p_jar
.
exportFile
(
subobject
.
_p_oid
,
String
IO
())
subobject
.
_p_oid
,
Bytes
IO
())
return
subobject_dict
return
subobject_dict
# XXX btsave is for backward compatibility
# XXX btsave is for backward compatibility
if
action
in
(
'backup'
,
'btsave'
,
'save_and_remove'
,):
if
action
in
(
'backup'
,
'btsave'
,
'save_and_remove'
,):
...
@@ -6161,8 +6161,8 @@ Business Template is a set of definitions, such as skins, portal types and categ
...
@@ -6161,8 +6161,8 @@ Business Template is a set of definitions, such as skins, portal types and categ
'_test_item'
,
'_message_translation_item'
,]
'_test_item'
,
'_message_translation_item'
,]
if
item_name
in
item_list_1
:
if
item_name
in
item_list_1
:
f1
=
String
IO
()
# for XML export of New Object
f1
=
Bytes
IO
()
# for XML export of New Object
f2
=
String
IO
()
# For XML export of Installed Object
f2
=
Bytes
IO
()
# For XML export of Installed Object
# Remove unneeded properties
# Remove unneeded properties
new_object
=
new_item
.
removeProperties
(
new_object
,
1
)
new_object
=
new_item
.
removeProperties
(
new_object
,
1
)
installed_object
=
installed_item
.
removeProperties
(
installed_object
,
1
)
installed_object
=
installed_item
.
removeProperties
(
installed_object
,
1
)
...
...
product/ERP5/Tool/TemplateTool.py
View file @
6015079d
...
@@ -48,7 +48,7 @@ from Products.ERP5.genbt5list import generateInformation
...
@@ -48,7 +48,7 @@ from Products.ERP5.genbt5list import generateInformation
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
tempfile
import
mkstemp
,
mkdtemp
from
tempfile
import
mkstemp
,
mkdtemp
from
Products.ERP5
import
_dtmldir
from
Products.ERP5
import
_dtmldir
from
io
import
String
IO
from
io
import
Bytes
IO
from
urllib.request
import
pathname2url
,
urlopen
,
urlretrieve
from
urllib.request
import
pathname2url
,
urlopen
,
urlretrieve
from
urllib.parse
import
splittype
from
urllib.parse
import
splittype
import
urllib.request
,
urllib
.
error
,
urllib
.
parse
import
urllib.request
,
urllib
.
error
,
urllib
.
parse
...
@@ -305,7 +305,7 @@ class TemplateTool (BaseTool):
...
@@ -305,7 +305,7 @@ class TemplateTool (BaseTool):
bt
=
Resource
(
url
)
bt
=
Resource
(
url
)
export_string
=
bt
.
get
().
get_body
()
export_string
=
bt
.
get
().
get_body
()
self
.
deleteContent
(
id
)
self
.
deleteContent
(
id
)
self
.
_importObjectFromFile
(
String
IO
(
export_string
),
id
=
id
)
self
.
_importObjectFromFile
(
Bytes
IO
(
export_string
),
id
=
id
)
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'manage_download'
)
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'manage_download'
)
def
manage_download
(
self
,
url
,
id
=
None
,
REQUEST
=
None
):
def
manage_download
(
self
,
url
,
id
=
None
,
REQUEST
=
None
):
...
@@ -395,7 +395,7 @@ class TemplateTool (BaseTool):
...
@@ -395,7 +395,7 @@ class TemplateTool (BaseTool):
"""
"""
Import Business Template from passed base64 encoded text.
Import Business Template from passed base64 encoded text.
"""
"""
import_file =
String
IO(decodestring(file_data))
import_file =
Bytes
IO(decodestring(file_data))
return self.importFile(import_file = import_file, id = id, REQUEST = REQUEST,
return self.importFile(import_file = import_file, id = id, REQUEST = REQUEST,
batch_mode = batch_mode, **kw)
batch_mode = batch_mode, **kw)
...
...
product/ERP5/Tool/TrashTool.py
View file @
6015079d
...
@@ -38,7 +38,7 @@ from zExceptions import BadRequest
...
@@ -38,7 +38,7 @@ from zExceptions import BadRequest
from
zLOG
import
LOG
,
WARNING
from
zLOG
import
LOG
,
WARNING
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
io
import
BytesIO
as
StringIO
from
io
import
BytesIO
class
TrashTool
(
BaseTool
):
class
TrashTool
(
BaseTool
):
"""
"""
...
@@ -146,7 +146,7 @@ class TrashTool(BaseTool):
...
@@ -146,7 +146,7 @@ class TrashTool(BaseTool):
for
subobject_id
in
list
(
obj
.
objectIds
()):
for
subobject_id
in
list
(
obj
.
objectIds
()):
subobject
=
obj
[
subobject_id
]
subobject
=
obj
[
subobject_id
]
subobjects_dict
[
subobject_id
]
=
subobject
.
_p_jar
.
exportFile
(
subobjects_dict
[
subobject_id
]
=
subobject
.
_p_jar
.
exportFile
(
subobject
.
_p_oid
,
String
IO
())
subobject
.
_p_oid
,
Bytes
IO
())
if
save
:
# remove subobjecs from backup object
if
save
:
# remove subobjecs from backup object
obj
.
_delObject
(
subobject_id
)
obj
.
_delObject
(
subobject_id
)
...
...
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.TextDocument.py
View file @
6015079d
...
@@ -174,7 +174,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
...
@@ -174,7 +174,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
# Include extra parameter for image conversions
# Include extra parameter for image conversions
temp_image
=
self
.
portal_contributions
.
newContent
(
temp_image
=
self
.
portal_contributions
.
newContent
(
portal_type
=
'Image'
,
portal_type
=
'Image'
,
file
=
io
.
String
IO
(),
file
=
io
.
Bytes
IO
(),
filename
=
self
.
getId
(),
filename
=
self
.
getId
(),
temp_object
=
1
)
temp_object
=
1
)
temp_image
.
_setData
(
result
)
temp_image
.
_setData
(
result
)
...
...
product/ERP5/bootstrap/erp5_core/MixinTemplateItem/portal_components/mixin.erp5.BaseConvertableFileMixin.py
View file @
6015079d
...
@@ -31,7 +31,7 @@ from AccessControl import ClassSecurityInfo
...
@@ -31,7 +31,7 @@ from AccessControl import ClassSecurityInfo
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
from
OFS.Image
import
Pdata
from
OFS.Image
import
Pdata
from
io
import
String
IO
from
io
import
Bytes
IO
_MARKER
=
object
()
_MARKER
=
object
()
class
BaseConvertableFileMixin
:
class
BaseConvertableFileMixin
:
...
@@ -96,7 +96,7 @@ class BaseConvertableFileMixin:
...
@@ -96,7 +96,7 @@ class BaseConvertableFileMixin:
"""Wrap value into Pdata
"""Wrap value into Pdata
"""
"""
if
not
isinstance
(
data
,
Pdata
)
and
data
is
not
None
:
if
not
isinstance
(
data
,
Pdata
)
and
data
is
not
None
:
file_
=
String
IO
(
data
)
file_
=
Bytes
IO
(
data
)
data
,
_
=
self
.
_read_data
(
file_
)
data
,
_
=
self
.
_read_data
(
file_
)
self
.
_baseSetBaseData
(
data
)
self
.
_baseSetBaseData
(
data
)
...
...
product/ERP5/bootstrap/erp5_core/ModuleComponentTemplateItem/portal_components/module.erp5.WebDAVSupport.py
View file @
6015079d
...
@@ -23,7 +23,7 @@ from Products.ERP5Type.Globals import InitializeClass
...
@@ -23,7 +23,7 @@ from Products.ERP5Type.Globals import InitializeClass
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
from
Products.CMFCore.PortalContent
import
ResourceLockedError
from
Products.CMFCore.PortalContent
import
ResourceLockedError
from
zExceptions
import
Forbidden
from
zExceptions
import
Forbidden
from
io
import
String
IO
from
io
import
Bytes
IO
security
=
ModuleSecurityInfo
(
__name__
)
security
=
ModuleSecurityInfo
(
__name__
)
...
@@ -77,7 +77,7 @@ class TextContent:
...
@@ -77,7 +77,7 @@ class TextContent:
headers
=
self
.
parseHeadersFromText
(
body
)
headers
=
self
.
parseHeadersFromText
(
body
)
content_type
=
REQUEST
.
get_header
(
'Content-Type'
,
''
)
content_type
=
REQUEST
.
get_header
(
'Content-Type'
,
''
)
headers
.
setdefault
(
'content_type'
,
content_type
)
headers
.
setdefault
(
'content_type'
,
content_type
)
headers
[
'file'
]
=
String
IO
(
body
)
headers
[
'file'
]
=
Bytes
IO
(
body
)
self
.
_edit
(
**
headers
)
self
.
_edit
(
**
headers
)
except
ResourceLockedError
:
except
ResourceLockedError
:
transaction
.
abort
()
transaction
.
abort
()
...
...
product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.ContributionTool.py
View file @
6015079d
...
@@ -168,7 +168,7 @@ class ContributionTool(BaseTool):
...
@@ -168,7 +168,7 @@ class ContributionTool(BaseTool):
except
KeyError
:
except
KeyError
:
raise
ValueError
(
'data must be provided'
)
raise
ValueError
(
'data must be provided'
)
if
data
is
not
None
:
if
data
is
not
None
:
file_object
=
io
.
String
IO
()
file_object
=
io
.
Bytes
IO
()
file_object
.
write
(
data
)
file_object
.
write
(
data
)
file_object
.
seek
(
0
)
file_object
.
seek
(
0
)
kw
[
'file'
]
=
file_object
kw
[
'file'
]
=
file_object
...
@@ -638,7 +638,7 @@ class ContributionTool(BaseTool):
...
@@ -638,7 +638,7 @@ class ContributionTool(BaseTool):
url_file
=
urllib
.
request
.
urlopen
(
urllib
.
request
.
Request
(
url
,
url_file
=
urllib
.
request
.
urlopen
(
urllib
.
request
.
Request
(
url
,
headers
=
{
'Accept'
:
'*/*'
}))
headers
=
{
'Accept'
:
'*/*'
}))
data
=
url_file
.
read
()
# time out must be set or ... too long XXX
data
=
url_file
.
read
()
# time out must be set or ... too long XXX
file_object
=
io
.
String
IO
()
file_object
=
io
.
Bytes
IO
()
file_object
.
write
(
data
)
file_object
.
write
(
data
)
file_object
.
seek
(
0
)
file_object
.
seek
(
0
)
# if a content-disposition header is present,
# if a content-disposition header is present,
...
...
product/ERP5Form/PDFTemplate.py
View file @
6015079d
...
@@ -220,7 +220,7 @@ if ReportTool:
...
@@ -220,7 +220,7 @@ if ReportTool:
from
Products.CMFReportTool.RenderPDF.Parser
import
TemplateParser
,
DocumentParser
from
Products.CMFReportTool.RenderPDF.Parser
import
TemplateParser
,
DocumentParser
from
Products.PageTemplates.Expressions
import
boboAwareZopeTraverse
from
Products.PageTemplates.Expressions
import
boboAwareZopeTraverse
from
io
import
String
IO
from
io
import
Bytes
IO
import
xml.dom.minidom
import
xml.dom.minidom
import
urllib.request
,
urllib
.
parse
,
urllib
.
error
,
os
.
path
import
urllib.request
,
urllib
.
parse
,
urllib
.
error
,
os
.
path
...
@@ -254,7 +254,7 @@ if ReportTool:
...
@@ -254,7 +254,7 @@ if ReportTool:
elif
hasattr
(
obj
,
'data'
):
elif
hasattr
(
obj
,
'data'
):
obj
=
obj
.
data
obj
=
obj
.
data
return
String
IO
(
str
(
obj
))
return
Bytes
IO
(
str
(
obj
))
else
:
else
:
class
ERP5ResourceHandler
(
ResourceHandler
):
class
ERP5ResourceHandler
(
ResourceHandler
):
''' Wrapper for ZODB Resources and files'''
''' Wrapper for ZODB Resources and files'''
...
@@ -287,7 +287,7 @@ if ReportTool:
...
@@ -287,7 +287,7 @@ if ReportTool:
elif
hasattr
(
obj
,
'data'
):
elif
hasattr
(
obj
,
'data'
):
obj
=
obj
.
data
obj
=
obj
.
data
return
String
IO
(
str
(
obj
))
return
Bytes
IO
(
str
(
obj
))
...
@@ -329,7 +329,7 @@ if ReportTool:
...
@@ -329,7 +329,7 @@ if ReportTool:
document
=
DocumentParser
(
document_dom
,
encoding
,
resourceHandler
=
rhandler
)
document
=
DocumentParser
(
document_dom
,
encoding
,
resourceHandler
=
rhandler
)
# create the PDF itself using the document and the template
# create the PDF itself using the document and the template
buf
=
String
IO
()
buf
=
Bytes
IO
()
document
(
template
,
buf
)
document
(
template
,
buf
)
buf
.
seek
(
0
)
buf
.
seek
(
0
)
return
buf
.
read
()
return
buf
.
read
()
...
...
product/ERP5OOo/OOoTemplate.py
View file @
6015079d
...
@@ -43,7 +43,7 @@ from Acquisition import aq_base
...
@@ -43,7 +43,7 @@ from Acquisition import aq_base
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
.OOoUtils
import
OOoBuilder
from
.OOoUtils
import
OOoBuilder
from
zipfile
import
ZipFile
,
ZIP_DEFLATED
from
zipfile
import
ZipFile
,
ZIP_DEFLATED
from
io
import
String
IO
from
io
import
Bytes
IO
import
re
import
re
import
itertools
import
itertools
import
six
import
six
...
@@ -225,7 +225,7 @@ class OOoTemplate(ZopePageTemplate):
...
@@ -225,7 +225,7 @@ class OOoTemplate(ZopePageTemplate):
self
.
OLE_documents_zipstring
=
None
self
.
OLE_documents_zipstring
=
None
# create a zip archive and store it
# create a zip archive and store it
if
attached_files_list
:
if
attached_files_list
:
memory_file
=
String
IO
()
memory_file
=
Bytes
IO
()
try
:
try
:
zf
=
ZipFile
(
memory_file
,
mode
=
'w'
,
compression
=
ZIP_DEFLATED
)
zf
=
ZipFile
(
memory_file
,
mode
=
'w'
,
compression
=
ZIP_DEFLATED
)
except
RuntimeError
:
except
RuntimeError
:
...
...
product/ERP5OOo/OOoUtils.py
View file @
6015079d
...
@@ -37,7 +37,7 @@ from xml.dom import Node
...
@@ -37,7 +37,7 @@ from xml.dom import Node
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Globals
import
InitializeClass
,
get_request
from
Products.ERP5Type.Globals
import
InitializeClass
,
get_request
from
zipfile
import
ZipFile
,
ZIP_DEFLATED
from
zipfile
import
ZipFile
,
ZIP_DEFLATED
from
io
import
String
IO
from
io
import
Bytes
IO
import
imghdr
import
imghdr
import
random
import
random
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
...
@@ -73,7 +73,7 @@ class OOoBuilder(Implicit):
...
@@ -73,7 +73,7 @@ class OOoBuilder(Implicit):
def
__init__
(
self
,
document
):
def
__init__
(
self
,
document
):
if
hasattr
(
document
,
'data'
)
:
if
hasattr
(
document
,
'data'
)
:
self
.
_document
=
String
IO
()
self
.
_document
=
Bytes
IO
()
if
isinstance
(
document
.
data
,
Pdata
):
if
isinstance
(
document
.
data
,
Pdata
):
# Handle image included in the style
# Handle image included in the style
...
@@ -88,7 +88,7 @@ class OOoBuilder(Implicit):
...
@@ -88,7 +88,7 @@ class OOoBuilder(Implicit):
elif
hasattr
(
document
,
'read'
)
:
elif
hasattr
(
document
,
'read'
)
:
self
.
_document
=
document
self
.
_document
=
document
else
:
else
:
self
.
_document
=
String
IO
()
self
.
_document
=
Bytes
IO
()
self
.
_document
.
write
(
document
)
self
.
_document
.
write
(
document
)
self
.
_image_count
=
0
self
.
_image_count
=
0
self
.
_manifest_additions_list
=
[]
self
.
_manifest_additions_list
=
[]
...
@@ -143,7 +143,7 @@ class OOoBuilder(Implicit):
...
@@ -143,7 +143,7 @@ class OOoBuilder(Implicit):
- indent the xml
- indent the xml
"""
"""
content_xml
=
self
.
extract
(
ooo_xml_file_id
)
content_xml
=
self
.
extract
(
ooo_xml_file_id
)
output
=
String
IO
()
output
=
Bytes
IO
()
content_doc
=
etree
.
XML
(
content_xml
)
content_doc
=
etree
.
XML
(
content_xml
)
root
=
content_doc
.
getroottree
().
getroot
()
root
=
content_doc
.
getroottree
().
getroot
()
#Declare zope namespaces
#Declare zope namespaces
...
@@ -232,7 +232,7 @@ class OOoParser(Implicit):
...
@@ -232,7 +232,7 @@ class OOoParser(Implicit):
self
.
filename
=
None
self
.
filename
=
None
def
openFromString
(
self
,
text_content
):
def
openFromString
(
self
,
text_content
):
return
self
.
openFile
(
String
IO
(
text_content
))
return
self
.
openFile
(
Bytes
IO
(
text_content
))
def
openFile
(
self
,
file_descriptor
):
def
openFile
(
self
,
file_descriptor
):
"""
"""
...
...
product/ERP5OOo/tests/TestFormPrintoutMixin.py
View file @
6015079d
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
io
import
String
IO
from
io
import
Bytes
IO
class
TestFormPrintoutMixin
(
ERP5TypeTestCase
):
class
TestFormPrintoutMixin
(
ERP5TypeTestCase
):
run_all_test
=
1
run_all_test
=
1
...
@@ -55,7 +55,7 @@ class TestFormPrintoutMixin(ERP5TypeTestCase):
...
@@ -55,7 +55,7 @@ class TestFormPrintoutMixin(ERP5TypeTestCase):
'''return odf document from the printout
'''return odf document from the printout
'''
'''
document_file
=
getattr
(
self
.
portal
,
printout_form
.
template
,
None
)
document_file
=
getattr
(
self
.
portal
,
printout_form
.
template
,
None
)
document_file
=
String
IO
(
document_file
).
read
()
document_file
=
Bytes
IO
(
document_file
).
read
()
if
document_file
is
not
None
:
if
document_file
is
not
None
:
return
document_file
return
document_file
raise
ValueError
(
'%s template not found'
%
printout_form
.
template
)
raise
ValueError
(
'%s template not found'
%
printout_form
.
template
)
...
...
product/ERP5OOo/tests/testIngestion.py
View file @
6015079d
...
@@ -2108,7 +2108,7 @@ class Base_contributeMixin:
...
@@ -2108,7 +2108,7 @@ class Base_contributeMixin:
"""
"""
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
empty_file_upload
=
ZPublisher
.
HTTPRequest
.
FileUpload
(
FieldStorage
(
empty_file_upload
=
ZPublisher
.
HTTPRequest
.
FileUpload
(
FieldStorage
(
fp
=
io
.
String
IO
(),
fp
=
io
.
Bytes
IO
(),
environ
=
dict
(
REQUEST_METHOD
=
'PUT'
),
environ
=
dict
(
REQUEST_METHOD
=
'PUT'
),
headers
=
{
"content-disposition"
:
headers
=
{
"content-disposition"
:
"attachment; filename=empty;"
}))
"attachment; filename=empty;"
}))
...
...
product/ERP5OOo/tests/testOOoDynamicStyle.py
View file @
6015079d
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
import
os
import
os
import
unittest
import
unittest
from
io
import
String
IO
from
io
import
Bytes
IO
from
zipfile
import
ZipFile
from
zipfile
import
ZipFile
from
Products.ERP5Type.tests.utils
import
FileUpload
from
Products.ERP5Type.tests.utils
import
FileUpload
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
...
@@ -237,7 +237,7 @@ return getattr(context, "%s_%s" % (parameter, current_language))
...
@@ -237,7 +237,7 @@ return getattr(context, "%s_%s" % (parameter, current_language))
response
.
getHeader
(
'content-type'
).
split
(
';'
)[
0
])
response
.
getHeader
(
'content-type'
).
split
(
';'
)[
0
])
self
.
assertEqual
(
'attachment; filename="Base_viewIncludeImageAsOdt.odt"'
,
self
.
assertEqual
(
'attachment; filename="Base_viewIncludeImageAsOdt.odt"'
,
response
.
getHeader
(
'content-disposition'
))
response
.
getHeader
(
'content-disposition'
))
cs
=
String
IO
()
cs
=
Bytes
IO
()
cs
.
write
(
body
)
cs
.
write
(
body
)
zip_document
=
ZipFile
(
cs
)
zip_document
=
ZipFile
(
cs
)
picture_list
=
[
x
for
x
in
zip_document
.
infolist
()
if
"Pictures"
in
x
.
filename
]
picture_list
=
[
x
for
x
in
zip_document
.
infolist
()
if
"Pictures"
in
x
.
filename
]
...
...
product/ERP5OOo/tests/utils.py
View file @
6015079d
...
@@ -40,7 +40,7 @@ import tempfile
...
@@ -40,7 +40,7 @@ import tempfile
import
zipfile
import
zipfile
import
popen2
import
popen2
import
urllib.request
,
urllib
.
error
,
urllib
.
parse
import
urllib.request
,
urllib
.
error
,
urllib
.
parse
from
io
import
String
IO
from
io
import
Bytes
IO
try
:
try
:
import
lxml
import
lxml
...
@@ -65,14 +65,14 @@ if lxml:
...
@@ -65,14 +65,14 @@ if lxml:
def
validate
(
self
,
odf_file_content
):
def
validate
(
self
,
odf_file_content
):
error_list
=
[]
error_list
=
[]
odf_file
=
String
IO
(
odf_file_content
)
odf_file
=
Bytes
IO
(
odf_file_content
)
for
f
in
(
'content.xml'
,
'meta.xml'
,
'styles.xml'
,
'settings.xml'
):
for
f
in
(
'content.xml'
,
'meta.xml'
,
'styles.xml'
,
'settings.xml'
):
error_list
.
extend
(
self
.
_validateXML
(
odf_file
,
f
))
error_list
.
extend
(
self
.
_validateXML
(
odf_file
,
f
))
return
error_list
return
error_list
def
_validateXML
(
self
,
odf_file
,
content_file_name
):
def
_validateXML
(
self
,
odf_file
,
content_file_name
):
zfd
=
zipfile
.
ZipFile
(
odf_file
)
zfd
=
zipfile
.
ZipFile
(
odf_file
)
doc
=
lxml
.
etree
.
parse
(
String
IO
(
zfd
.
read
(
content_file_name
)))
doc
=
lxml
.
etree
.
parse
(
Bytes
IO
(
zfd
.
read
(
content_file_name
)))
return
[]
return
[]
# The following is the past implementation that validates with
# The following is the past implementation that validates with
# RelaxNG schema. But recent LibreOffice uses extended odf
# RelaxNG schema. But recent LibreOffice uses extended odf
...
...
product/ERP5Type/Base.py
View file @
6015079d
...
@@ -94,7 +94,6 @@ from zope.interface import classImplementsOnly, implementedBy
...
@@ -94,7 +94,6 @@ from zope.interface import classImplementsOnly, implementedBy
import
sys
,
re
import
sys
,
re
from
io
import
BytesIO
as
StringIO
from
socket
import
gethostname
,
gethostbyaddr
from
socket
import
gethostname
,
gethostbyaddr
import
random
import
random
...
@@ -2158,7 +2157,7 @@ class Base(
...
@@ -2158,7 +2157,7 @@ class Base(
# We must do an ordered list so we can not use the previous method
# We must do an ordered list so we can not use the previous method
# self._setValue(id, self.portal_catalog.getObjectList(uids), spec=spec)
# self._setValue(id, self.portal_catalog.getObjectList(uids), spec=spec)
references
=
[
self
.
getPortalObject
().
portal_catalog
.
getObject
(
x
)
references
=
[
self
.
getPortalObject
().
portal_catalog
.
getObject
(
x
)
for
x
in
((
uids
,)
if
isinstance
(
uids
,
int
)
else
uids
)]
for
x
in
((
uids
,)
if
isinstance
(
uids
,
six
.
integer_types
)
else
uids
)]
self
.
_setValue
(
id
,
references
,
spec
=
spec
,
filter
=
filter
,
portal_type
=
portal_type
,
self
.
_setValue
(
id
,
references
,
spec
=
spec
,
filter
=
filter
,
portal_type
=
portal_type
,
keep_default
=
keep_default
,
checked_permission
=
checked_permission
)
keep_default
=
keep_default
,
checked_permission
=
checked_permission
)
...
...
product/ERP5Type/mixin/json_representable.py
View file @
6015079d
...
@@ -37,7 +37,7 @@ except ImportError:
...
@@ -37,7 +37,7 @@ except ImportError:
DeprecationWarning
)
DeprecationWarning
)
import
zope.interface
import
zope.interface
from
Products.ERP5Type
import
XMLExportImport
from
Products.ERP5Type
import
XMLExportImport
from
io
import
BytesIO
as
StringIO
from
io
import
BytesIO
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.interfaces.json_representable
import
IJSONRepresentable
from
Products.ERP5Type.interfaces.json_representable
import
IJSONRepresentable
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
...
@@ -71,7 +71,7 @@ class JSONRepresentableMixin:
...
@@ -71,7 +71,7 @@ class JSONRepresentableMixin:
Gets the dict representation of the object
Gets the dict representation of the object
"""
"""
# Use OFS exportXML to first export to xml
# Use OFS exportXML to first export to xml
f
=
String
IO
()
f
=
Bytes
IO
()
XMLExportImport
.
exportXML
(
self
.
_p_jar
,
self
.
_p_oid
,
f
)
XMLExportImport
.
exportXML
(
self
.
_p_jar
,
self
.
_p_oid
,
f
)
# Get the value of exported XML
# Get the value of exported XML
...
@@ -88,7 +88,7 @@ class JSONRepresentableMixin:
...
@@ -88,7 +88,7 @@ class JSONRepresentableMixin:
# Convert the dict_value to XML representation
# Convert the dict_value to XML representation
xml_value
=
xmltodict
.
unparse
(
dict_value
)
xml_value
=
xmltodict
.
unparse
(
dict_value
)
f
=
String
IO
(
xml_value
)
f
=
Bytes
IO
(
xml_value
)
return
XMLExportImport
.
importXML
(
self
.
_p_jar
,
f
)
return
XMLExportImport
.
importXML
(
self
.
_p_jar
,
f
)
InitializeClass
(
JSONRepresentableMixin
)
InitializeClass
(
JSONRepresentableMixin
)
product/ERP5Type/patches/OFSImage.py
View file @
6015079d
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
"""
"""
import
OFS.Image
import
OFS.Image
import
struct
import
struct
from
io
import
BytesIO
as
StringIO
from
io
import
BytesIO
from
zExceptions
import
Forbidden
from
zExceptions
import
Forbidden
def
getImageInfo_with_svg_fix
(
data
):
def
getImageInfo_with_svg_fix
(
data
):
...
@@ -57,7 +57,7 @@ def getImageInfo_with_svg_fix(data):
...
@@ -57,7 +57,7 @@ def getImageInfo_with_svg_fix(data):
# handle JPEGs
# handle JPEGs
elif
(
size
>=
2
)
and
(
data
[:
2
]
==
'
\
377
\
330
'
):
elif
(
size
>=
2
)
and
(
data
[:
2
]
==
'
\
377
\
330
'
):
content_type
=
'image/jpeg'
content_type
=
'image/jpeg'
jpeg
=
String
IO
(
data
)
jpeg
=
Bytes
IO
(
data
)
jpeg
.
read
(
2
)
jpeg
.
read
(
2
)
b
=
jpeg
.
read
(
1
)
b
=
jpeg
.
read
(
1
)
try
:
try
:
...
...
product/ERP5Type/patches/urllib_opener.py
View file @
6015079d
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
# Install openers
# Install openers
# -> testTemplateTool.TestTemplateTool.test_getBusinessTemplateUrl
# -> testTemplateTool.TestTemplateTool.test_getBusinessTemplateUrl
import
urllib.request
,
urllib
.
parse
,
urllib
.
error
import
urllib.request
,
urllib
.
parse
,
urllib
.
error
from
io
import
BytesIO
as
StringIO
from
io
import
BytesIO
import
socket
import
socket
import
os
import
os
import
mimetypes
import
mimetypes
...
@@ -72,7 +72,7 @@ class DirectoryFileHandler(urllib.request.FileHandler):
...
@@ -72,7 +72,7 @@ class DirectoryFileHandler(urllib.request.FileHandler):
size
=
stats
.
st_size
size
=
stats
.
st_size
modified
=
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
modified
=
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
mtype
=
mimetypes
.
guess_type
(
file
)[
0
]
mtype
=
mimetypes
.
guess_type
(
file
)[
0
]
headers
=
message_from_bytes
(
String
IO
(
headers
=
message_from_bytes
(
Bytes
IO
(
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
(
mtype
or
'text/plain'
,
size
,
modified
)))
(
mtype
or
'text/plain'
,
size
,
modified
)))
if
host
:
if
host
:
...
@@ -81,14 +81,14 @@ class DirectoryFileHandler(urllib.request.FileHandler):
...
@@ -81,14 +81,14 @@ class DirectoryFileHandler(urllib.request.FileHandler):
(
not
port
and
socket
.
gethostbyname
(
host
)
in
self
.
get_names
()):
(
not
port
and
socket
.
gethostbyname
(
host
)
in
self
.
get_names
()):
try
:
try
:
file_list
=
os
.
listdir
(
localfile
)
file_list
=
os
.
listdir
(
localfile
)
s
=
String
IO
()
s
=
Bytes
IO
()
s
.
write
(
'<html><head><base href="%s"/></head><body>'
%
(
'file:'
+
file
))
s
.
write
(
'<html><head><base href="%s"/></head><body>'
%
(
'file:'
+
file
))
s
.
write
(
'<p>Directory Content:</p>'
)
s
.
write
(
'<p>Directory Content:</p>'
)
for
f
in
file_list
:
for
f
in
file_list
:
s
.
write
(
'<p><a href="%s">%s</a></p>
\
n
'
%
(
urllib
.
parse
.
quote
(
f
),
f
))
s
.
write
(
'<p><a href="%s">%s</a></p>
\
n
'
%
(
urllib
.
parse
.
quote
(
f
),
f
))
s
.
write
(
'</body></html>'
)
s
.
write
(
'</body></html>'
)
s
.
seek
(
0
)
s
.
seek
(
0
)
headers
=
message_from_bytes
(
String
IO
(
headers
=
message_from_bytes
(
Bytes
IO
(
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
(
'text/html'
,
size
,
modified
)))
(
'text/html'
,
size
,
modified
)))
return
urllib2
.
addinfourl
(
s
,
headers
,
'file:'
+
file
)
return
urllib2
.
addinfourl
(
s
,
headers
,
'file:'
+
file
)
...
...
product/ERP5Type/tests/ERP5TypeTestCase.py
View file @
6015079d
...
@@ -20,7 +20,7 @@ import time
...
@@ -20,7 +20,7 @@ import time
import
traceback
import
traceback
import
urllib.request
,
urllib
.
parse
,
urllib
.
error
import
urllib.request
,
urllib
.
parse
,
urllib
.
error
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
io
import
String
IO
from
io
import
Bytes
IO
from
six.moves
import
configparser
from
six.moves
import
configparser
from
six.moves.cPickle
import
dumps
from
six.moves.cPickle
import
dumps
from
glob
import
glob
from
glob
import
glob
...
@@ -824,9 +824,9 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
...
@@ -824,9 +824,9 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
return
orig_extractUserIds
(
pas
,
request
,
plugins
)
return
orig_extractUserIds
(
pas
,
request
,
plugins
)
if
stdin
is
None
:
if
stdin
is
None
:
stdin
=
String
IO
()
stdin
=
Bytes
IO
()
outstream
=
String
IO
()
outstream
=
Bytes
IO
()
response
=
Response
(
stdout
=
outstream
,
stderr
=
sys
.
stderr
)
response
=
Response
(
stdout
=
outstream
,
stderr
=
sys
.
stderr
)
try
:
try
:
...
...
product/ERP5Type/tests/Python3StyleTest.py
View file @
6015079d
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
import
os
,
sys
import
os
,
sys
import
unittest
import
unittest
from
subprocess
import
check_output
,
CalledProcessError
from
subprocess
import
check_output
,
CalledProcessError
from
io
import
String
IO
from
io
import
Bytes
IO
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
lib2to3.main
import
main
from
lib2to3.main
import
main
...
@@ -67,7 +67,7 @@ class Python3StyleTest(ERP5TypeTestCase):
...
@@ -67,7 +67,7 @@ class Python3StyleTest(ERP5TypeTestCase):
path
=
os
.
path
.
normpath
(
path
+
os
.
environ
[
'TESTED_PRODUCT'
])
path
=
os
.
path
.
normpath
(
path
+
os
.
environ
[
'TESTED_PRODUCT'
])
orig_stdout
=
sys
.
stdout
orig_stdout
=
sys
.
stdout
try
:
# XXX: not thread-safe
try
:
# XXX: not thread-safe
sys
.
stdout
=
stdout
=
String
IO
()
sys
.
stdout
=
stdout
=
Bytes
IO
()
returncode
=
main
(
"lib2to3.fixes"
,
[
"--fix"
,
fixer_name
,
path
])
returncode
=
main
(
"lib2to3.fixes"
,
[
"--fix"
,
fixer_name
,
path
])
finally
:
finally
:
sys
.
stdout
=
orig_stdout
sys
.
stdout
=
orig_stdout
...
...
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
6015079d
...
@@ -2781,8 +2781,8 @@ class TestGC(XMLObject):
...
@@ -2781,8 +2781,8 @@ class TestGC(XMLObject):
import
gc
import
gc
initial_gc_debug_flags
=
gc
.
get_debug
()
initial_gc_debug_flags
=
gc
.
get_debug
()
initial_stderr
=
sys
.
stderr
initial_stderr
=
sys
.
stderr
from
io
import
String
IO
from
io
import
Bytes
IO
stderr
=
String
IO
()
stderr
=
Bytes
IO
()
try
:
try
:
gc
.
disable
()
gc
.
disable
()
...
...
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