28feabd98aed1465b1d7caa636ae056fb8f8f2b3
2 ##title=Delete objects from a folder
4 request
= context
.REQUEST
5 response
= request
.RESPONSE
7 if request
.cookies
.has_key('__cp'):
8 contextPath
= context
.getPhysicalPath()
9 depth
= len(contextPath
) + 1
10 strContextPath
= ''.join(contextPath
)
12 cp
= context
.getCPInfo()
16 deletedObPaths
[strContextPath
+ id] = True
18 indexes
, paths
= [], cp
[1]
20 for i
in range(len(paths
)) :
23 firstPart
= path
[:depth
]
24 if deletedObPaths
.has_key(''.join(firstPart
)) :
26 except IndexError : continue
28 context
.popCP(indexes
)
31 ret
= context
.manage_delObjects( list(ids
) )
36 o
= getattr(context
, id, None)
38 ignored
.append(o
.title_or_id())
39 #TODO : translate messages
40 #from Products.PlacelessTranslationService.MessageID import MessageIDFactory
41 #_ = MessageIDFactory('plinn')
42 _
= lambda x
: lambda : x
43 translate
= lambda msg
: _(msg
)().decode('iso-8859-1').encode('utf-8')
44 msg
= translate('You are not allowed to delete: ') + ', '.join(ignored
)
46 msg
= msg
or 'Item%s deleted.' % ( len(ids
) != 1 and 's' or '' )
47 return context
.setStatus( True, msg
)