PUT webdav -> on crée un fichier pour le tout venant.
[Plinn.git] / skins / control / getUntitledContentName.py
1 ##parameters=
2
3 #TODO : translate messages
4 #from Products.PlacelessTranslationService.MessageID import MessageIDFactory
5 #_ = MessageIDFactory('plinn')
6 _ = lambda x : lambda : x
7
8 translate = lambda msg : _(msg)().decode('iso-8859-1').encode('utf-8')
9 portal = context.portal_url.getPortalObject()
10 ucn = translate(portal.getProperty('untitled_content_name', 'Untitled-'))
11 ucnl = len(ucn)
12
13 untitledNumbers = [ id[ucnl:] for id in context.objectIds() if id.startswith(ucn) ]
14 nMax = 0
15 for strN in untitledNumbers :
16 try :
17 n = int(strN)
18 if n > nMax : nMax = n
19 except :
20 pass
21
22 return ucn + str(nMax + 1)