fdebcad06b32021cd1fd90d122726db10e12972e
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
== 'deletePhoto' :
50 photo
= uidtool
.queryObject(fg('uid'))
52 parent
= photo
.getParentNode()
53 parent
.manage_delObjects([photo
.getId()])