devel/py-Products.ExternalEditor: Fix build with setuptools 58.0.0+

With hat:	python
This commit is contained in:
Po-Chuan Hsieh 2022-03-25 21:32:10 +08:00
parent e808339fa8
commit 617bcc40fc
No known key found for this signature in database
GPG key ID: 9A4BD10F002DD04B

View file

@ -0,0 +1,64 @@
--- Products/ExternalEditor/ExternalEditor.py.orig 2010-12-03 03:58:58 UTC
+++ Products/ExternalEditor/ExternalEditor.py
@@ -18,7 +18,7 @@
from string import join # For Zope 2.3 compatibility
import types
-import urllib
+import urllib.request, urllib.parse, urllib.error
from Acquisition import aq_inner, aq_base, aq_parent, Implicit
try:
from App.class_init import InitializeClass
@@ -55,11 +55,11 @@ class PDataStreamIterator:
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self.data is None:
- raise StopIteration
+ raise(StopIteration)
data = self.data.data
- self.data = self.data.next
+ self.data = self.data.__next__
return data
def registerCallback(cb):
@@ -125,8 +125,8 @@ class ExternalEditor(Implicit):
if title is not None:
if callable(title):
title = title()
- if isinstance(title, types.UnicodeType):
- title = unicode.encode(title, 'utf-8')
+ if isinstance(title, str):
+ title = str.encode(title, 'utf-8')
r.append('title:%s' % title)
if hasattr(aq_base(ob), 'content_type'):
@@ -214,7 +214,7 @@ class ExternalEditor(Implicit):
body = ob.read()
else:
# can't read it!
- raise 'BadRequest', 'Object does not support external editing'
+ raise BadRequest('Object does not support external editing')
if (HAVE_Z3_IFACE and IStreamIterator.providedBy(body) or
(not HAVE_Z3_IFACE) and IStreamIterator.isImplementedBy(body)):
@@ -287,7 +287,7 @@ def EditLink(self, object, borrow_lock=0, skip_data=0)
if skip_data:
query['skip_data'] = 1
url = "%s/externalEdit_/%s%s%s" % (aq_parent(aq_inner(object)).absolute_url(),
- urllib.quote(object.getId()),
+ urllib.parse.quote(object.getId()),
ext, querystr(query))
return ('<a href="%s" '
'title="Edit using external editor">'
@@ -302,7 +302,7 @@ def querystr(d):
"""Create a query string from a dict"""
if d:
return '?' + '&'.join(
- ['%s=%s' % (name, val) for name, val in d.items()])
+ ['%s=%s' % (name, val) for name, val in list(d.items())])
else:
return ''