8b564999f1f0e5528cbbe7728d9547d623e8a605
3 from Products
.Plinn
.utils
import makeValidId
4 from Products
.CMFCore
.utils
import getToolByName
6 utool
= getToolByName(context
, 'portal_url')
7 portal
= utool
.getPortalObject()
8 uidtool
= getToolByName(portal
, 'portal_uidhandler')
10 fg
= context
.REQUEST
.form
.get
14 if method
== 'normaliseAndCreatePath' :
15 normalizedPath
, uids
= [], []
17 path
= fg('path', '').split(' ') # séparateur : 0x09 (tabulation)
19 validId
= makeValidId(o
, part
, allow_dup
=1)
20 if o
.hasObject(validId
) :
21 normalizedPath
.append(validId
)
24 id = o
.invokeFactory('Portfolio', validId
, title
=part
)
26 normalizedPath
.append(id)
27 uid
= uidtool
.register(o
)
30 return '%s\n%s' % ('/'.join(normalizedPath
), ' '.join([str(uid
) for uid
in uids
]))
32 elif method
== 'uploadPhoto' :
33 path
= fg('normalizedPath')
35 portfolio
= portal
.restrictedTraverse(path
)
36 photoId
= makeValidId(portfolio
, name
, allow_dup
=1)
37 if portfolio
.hasObject(photoId
) :
38 photo
= portfolio
[photoId
]
39 photo
.manage_upload(fg('photo'))
41 id = portfolio
.invokeFactory('Photo',
44 content_type
='image/jpeg')
45 photo
= portfolio
[photoId
]
46 uid
= uidtool
.register(photo
)
47 return '%s %s' % (uid
, photo
.absolute_url())
49 elif method
in ('deletePhoto', 'deletePortfolio') :
50 o
= uidtool
.queryObject(fg('uid'))
52 parent
= o
.getParentNode()
53 parent
.manage_delObjects([o
.getId()])