request container REQUEST RESPONSE request RESPONSE from DateTime impo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
request = container.REQUEST
RESPONSE = request.RESPONSE
from DateTime import DateTime
batch_size = int(batch_size)
tmp_id = src + '_1'
f = context.restrictedTraverse(src)
if tmp_id not in context.objectIds():
context.invokeFactory('Large Plone Folder', tmp_id)
tmp = context[tmp_id]
if batch_size < len(f.objectIds()):
start = DateTime()
tmp.manage_pasteObjects(f.manage_cutObjects(f.objectIds()[:batch_size]))
end = DateTime()
print """
<html>
<head>
<meta http-equiv="refresh" content="5" />
<title>Moving...</title>
</head>
<body>
<p>Moving...</p>
Moved %d items from "%s" to "%s" at %s sec.
Last %d
</body>
</html>
""" % (batch_size, f.getId(), tmp.getId(), 100000*(end-start), len(f.objectIds()))
else:
tmp.manage_pasteObjects(f.manage_cutObjects(f.objectIds()))
context.manage_delObjects([src])
context.manage_renameObjects([src+'_1'], [src])
#objs = context.manage_cutObjects([src + '_1'])
#context.manage_pasteObjects(objs)
print """
<html>
<head>
<title>Moving finished!!!</title>
</head>
<body>
<p>Moving finished!!!</p>
Moved all %d items from "%s" to "%s".
</body>
</html>
""" % (len(tmp.objectIds()), f.getId(), tmp.getId())
return printed