Commit dabb9766 authored by Hanno Schlichting's avatar Hanno Schlichting

Restore `__cp` cookie, as it is also used by downstream projects.

parent 86a623e5
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
"""Copy interface """Copy interface
""" """
from marshal import dumps from json import dumps
from marshal import loads from json import loads
import re import re
import tempfile import tempfile
from urllib import quote from urllib import quote
...@@ -111,6 +111,10 @@ class CopyContainer(Base): ...@@ -111,6 +111,10 @@ class CopyContainer(Base):
oblist.append(m.dump()) oblist.append(m.dump())
cp = (1, oblist) cp = (1, oblist)
cp = _cb_encode(cp) cp = _cb_encode(cp)
if REQUEST is not None:
resp = REQUEST['RESPONSE']
resp.setCookie('__cp', cp, path='%s' % cookie_path(REQUEST))
REQUEST['__cp'] = cp
return cp return cp
security.declareProtected(view_management_screens, 'manage_copyObjects') security.declareProtected(view_management_screens, 'manage_copyObjects')
...@@ -132,6 +136,10 @@ class CopyContainer(Base): ...@@ -132,6 +136,10 @@ class CopyContainer(Base):
oblist.append(m.dump()) oblist.append(m.dump())
cp = (0, oblist) cp = (0, oblist)
cp = _cb_encode(cp) cp = _cb_encode(cp)
if REQUEST is not None:
resp = REQUEST['RESPONSE']
resp.setCookie('__cp', cp, path='%s' % cookie_path(REQUEST))
REQUEST['__cp'] = cp
return cp return cp
def _get_id(self, id): def _get_id(self, id):
...@@ -163,6 +171,8 @@ class CopyContainer(Base): ...@@ -163,6 +171,8 @@ class CopyContainer(Base):
or IObjectWillBeMovedEvent and IObjectMovedEvent. or IObjectWillBeMovedEvent and IObjectMovedEvent.
""" """
cp = cb_copy_data cp = cb_copy_data
if cp is None and REQUEST is not None and '__cp' in REQUEST:
cp = REQUEST['__cp']
if cp is None: if cp is None:
raise CopyError('No clipboard data found.') raise CopyError('No clipboard data found.')
...@@ -277,6 +287,13 @@ class CopyContainer(Base): ...@@ -277,6 +287,13 @@ class CopyContainer(Base):
# try to make ownership implicit if possible # try to make ownership implicit if possible
ob.manage_changeOwnershipType(explicit=0) ob.manage_changeOwnershipType(explicit=0)
if REQUEST is not None:
REQUEST['RESPONSE'].setCookie(
'__cp', 'deleted',
path='%s' % cookie_path(REQUEST),
expires='Wed, 31-Dec-97 23:59:59 GMT')
REQUEST['__cp'] = None
return result return result
security.declareProtected(view_management_screens, 'manage_renameObjects') security.declareProtected(view_management_screens, 'manage_renameObjects')
...@@ -540,7 +557,7 @@ def absattr(attr): ...@@ -540,7 +557,7 @@ def absattr(attr):
def _cb_encode(d): def _cb_encode(d):
return quote(compress(dumps(d), 9)) return quote(compress(dumps(d), 2))
def _cb_decode(s, maxsize=8192): def _cb_decode(s, maxsize=8192):
...@@ -549,3 +566,9 @@ def _cb_decode(s, maxsize=8192): ...@@ -549,3 +566,9 @@ def _cb_decode(s, maxsize=8192):
if dec.unconsumed_tail: if dec.unconsumed_tail:
raise ValueError raise ValueError
return loads(data) return loads(data)
def cookie_path(request):
# Return a "path" value for use in a cookie that refers
# to the root of the Zope object space.
return request['BASEPATH1'] or "/"
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