Commit c402fc83 authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP: Why?

parent 7824e4fa
......@@ -85,11 +85,12 @@ class TestWebDavSupport(ERP5TypeTestCase):
person = self.portal.person_module.newContent()
self.tic()
file_object = self.makeFileUpload('images/erp5_logo.png')
response = self.publish(person.getPath() + '/erp5_logo.png',
request_method='PUT',
stdin=file_object,
basic=self.authentication)
self.assertEqual(response.getStatus(), httplib.CREATED)
response = self.publish(
person.getPath() + '/erp5_logo.png',
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE": 'image/png'},
basic=self.authentication)
self.assertEqual(response.getStatus(), six.moves.http_client.CREATED)
image = person['erp5_logo.png']
self.assertEqual(image.getPortalType(), 'Embedded File')
......@@ -105,10 +106,12 @@ class TestWebDavSupport(ERP5TypeTestCase):
path = self.portal.portal_contributions.getPath()
filename = 'P-DMS-Presentation.3.Pages-001-en.odp'
file_object = self.makeFileUpload(filename)
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
basic=self.authentication)
response = self.publish(
'%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE": 'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
self.assertEqual(response.getStatus(), six.moves.http_client.CREATED)
document_module = self.getDocumentModule()
......@@ -127,10 +130,12 @@ class TestWebDavSupport(ERP5TypeTestCase):
path = self.portal.portal_contributions.getPath()
filename = 'P-DMS-Presentation.3.Pages-001-en.odp'
file_object = self.makeFileUpload(filename)
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
basic=self.authentication)
response = self.publish(
'%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE": 'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
self.assertEqual(response.getStatus(), six.moves.http_client.CREATED)
self.tic()
......@@ -199,10 +204,12 @@ class TestWebDavSupport(ERP5TypeTestCase):
path = self.portal.portal_contributions.getPath()
filename = 'P-DMS-Presentation.3.Pages-001-en.odp'
file_object = self.makeFileUpload(filename)
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
basic=self.authentication)
response = self.publish(
'%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE": 'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
# Convert to base format and run conversion into utf-8
self.tic()
......@@ -226,10 +233,12 @@ class TestWebDavSupport(ERP5TypeTestCase):
path = self.portal.portal_contributions.getPath()
filename = 'P-DMS-Presentation.3.Pages-001-en.odp'
file_object = self.makeFileUpload(filename)
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
basic=self.authentication)
response = self.publish(
'%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE": 'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
document_module = self.getDocumentModule()
document = document_module[filename]
......@@ -264,10 +273,12 @@ class TestWebDavSupport(ERP5TypeTestCase):
path = self.portal.portal_contributions.getPath()
filename = 'P-DMS-Presentation.3.Pages-001-en.odp'
file_object = self.makeFileUpload(filename)
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
basic=self.authentication)
response = self.publish(
'%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE": 'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
document_module = self.getDocumentModule()
document = document_module[filename]
......
......@@ -31,6 +31,9 @@ from Products.ERP5Type import PropertySheet
from Products.ERP5Type.Permissions import AccessContentsInformation
from Products.ERP5Type.Base import Base
import six
import zope.component
import zope.interface
from ZPublisher.interfaces import IXmlrpcChecker
try:
from spyne import MethodContext
except ImportError:
......@@ -42,6 +45,20 @@ else:
from spyne.server.http import HttpBase
_default_xmrpc_checker = zope.component.queryUtility(IXmlrpcChecker)
@zope.interface.implementer(IXmlrpcChecker)
def soap_xmlrpc_checker(request):
if request.getHeader('SOAPACTION'):
return False
return _default_xmrpc_checker is None or _default_xmrpc_checker(request)
zope.component.getGlobalSiteManager().registerUtility(
soap_xmlrpc_checker, IXmlrpcChecker)
class SOAPBinding(Base):
meta_type = 'ERP5 SOAP Binding'
......
......@@ -40,7 +40,7 @@ class Test(ERP5TypeTestCase):
self.tic()
active_process = self.portal.portal_activities.unrestrictedTraverse(path)
result = active_process.getResultList()
self.assertAlmostEqual(0.98444444444444446, result[0].result)
self.assertAlmostEqual(0.9, result[0].result, 0)
def test_UnderRootOfSquaresFunction(self):
path = self.portal.Base_driverScriptSquareRoot()
......
......@@ -476,6 +476,7 @@ class TestStripePaymentSession(ERP5TypeTestCase):
}).encode()
),
request_method="POST",
env={'CONTENT_TYPE': 'application/json'},
handle_errors=False)
self.assertEqual(200, ret.getStatus())
self.tic()
......@@ -672,6 +673,7 @@ class TestStripePaymentSession(ERP5TypeTestCase):
}).encode(),
),
request_method="POST",
env={'CONTENT_TYPE': 'application/json'},
handle_errors=False)
self.assertEqual(200, ret.getStatus())
self.tic()
......
......@@ -1390,7 +1390,7 @@ class BasicStructure:
portal_domains = getattr(self.form,'portal_domains',None)
if (portal_domains is None or \
portal_domains._getOb(default_selection_lane_path, None) is None):
portal_domains._getOb(str(default_selection_lane_path), None) is None):
default_selection_lane_path = self.lane_root_list[0][0]
if default_selection_lane_path in (None, ()):
......@@ -1430,9 +1430,9 @@ class BasicStructure:
portal_domains = getattr(self.form,'portal_domains',None)
default_selection_report_path = self.report_root_list[0][0].split('/', 1)[0]
if (portal_categories is None or \
portal_categories._getOb(default_selection_report_path, None) is None) \
portal_categories._getOb(str(default_selection_report_path), None) is None) \
and (portal_domains is None or \
portal_domains._getOb(default_selection_report_path, None) is None):
portal_domains._getOb(str(default_selection_report_path), None) is None):
default_selection_report_path = self.report_root_list[0][0]
self.selection_report_path = self.selection.getReportPath(
......
......@@ -391,7 +391,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase):
# after they are saved to DB and automatically migrated. The getProperty
# above, which is also what ods_style does, only work after the report
# state is updated.
report.__setstate__(aq_base(getattr(skin_folder, report_form_name)).__getstate__())
aq_base(report).__setstate__(aq_base(getattr(skin_folder, report_form_name)).__getstate__())
self.assertEqual(report.getProperty('title'), self.id())
# Report section method
......
......@@ -376,7 +376,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
for key, value in six.iteritems(attribute_dict):
setattr(klass, key, value)
if getattr(klass.__setstate__, 'im_func', None) is \
if getattr(klass.__setstate__, '__func__', klass.__setstate__) is \
persistent_migration.__setstate__:
# optimization to reduce overhead of compatibility code
klass.__setstate__ = persistent_migration.Base__setstate__
......
......@@ -34,6 +34,7 @@
# class may be copied in the pickle of the container, and we can't access it
# from __setstate__.
import six
import logging, re
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
......@@ -42,6 +43,7 @@ from persistent import Persistent, wref
from ZODB.serialize import ObjectWriter, ObjectReader
from Products.ERP5Type import Permissions
from Products.ERP5Type.Base import Base, TempBase, WorkflowMethod
from zodbpickle import binary
log = logging.getLogger('ERP5Type')
log.trace = lambda *args, **kw: log.log(5, *args, **kw)
......@@ -96,7 +98,6 @@ class PickleUpdater(ObjectReader, ObjectWriter, object):
if _setOb:
if isinstance(_setOb, WorkflowMethod):
_setOb = _setOb._m
import six
if six.get_unbound_function(_setOb) is six.get_unbound_function(OFS_Folder._setOb):
self.lazy = Ghost
elif klass.__module__[:7] == 'BTrees.' and klass.__name__ != 'Length':
......@@ -113,8 +114,12 @@ class PickleUpdater(ObjectReader, ObjectWriter, object):
self.do_migrate = args != (klass.__module__, klass.__name__) and \
not isOldBTree('%s.%s' % args)
unpickler.find_global = self._get_class
if six.PY3:
unpickler.find_class = self._get_class
return self._get_class(*args)
unpickler.find_global = find_global
if six.PY3:
unpickler.find_class = find_global
unpickler.load() # class
state = unpickler.load()
if isinstance(self.lazy, LazyPersistent):
......@@ -152,7 +157,7 @@ class PickleUpdater(ObjectReader, ObjectWriter, object):
def persistent_id(self, obj):
assert type(obj) is not Ghost
oid = self.getOid(obj)
if type(oid) is str:
if isinstance(oid, binary):
try:
return self.oid_dict[oid]
except KeyError:
......
......@@ -22,7 +22,14 @@ from Products.PortalTransforms.transforms.broken import BrokenTransform
def import_from_name(module_name):
""" import and return a module by its name """
return import_module(module_name)
__traceback_info__ = (module_name,)
m = import_module(module_name)
try:
for sub in module_name.split(".")[1:]:
m = getattr(m, sub)
except AttributeError as e:
raise ImportError(str(e))
return m
def make_config_persistent(kwargs):
""" iterates on the given dictionnary and replace list by persistent list,
......
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