Affichage du diaporama flash.
[Portfolio.git] / skins / lrservice.py
1 ##parameters=
2
3 from Products.Plinn.utils import makeValidId
4 from Products.CMFCore.utils import getToolByName
5
6 utool = getToolByName(context, 'portal_url')
7 portal = utool.getPortalObject()
8 uidtool = getToolByName(portal, 'portal_uidhandler')
9
10 fg = context.REQUEST.form.get
11
12 method = fg('method')
13
14 if method == 'normaliseAndCreatePath' :
15 normalizedPath = []
16 o = portal
17 path = fg('path', '').split('/')
18 for part in path :
19 validId = makeValidId(o, part, allow_dup=1)
20 if o.hasObject(validId) :
21 normalizedPath.append(validId)
22 o = o[validId]
23 else :
24 id = o.invokeFactory('Portfolio', validId, title=part)
25 o = o[id]
26 normalizedPath.append(id)
27
28 return '/'.join(normalizedPath)
29
30 elif method == 'uploadPhoto' :
31 path = fg('normalizedPath')
32 name = fg('fileName')
33 portfolio = portal.restrictedTraverse(path)
34 photoId = makeValidId(portfolio, name, allow_dup=1)
35 if portfolio.hasObject(photoId) :
36 photo = portfolio[photoId]
37 photo.manage_upload(fg('photo'))
38 else :
39 id = portfolio.invokeFactory('Photo',
40 photoId,
41 file=fg('photo'),
42 content_type='image/jpeg')
43 photo = portfolio[photoId]
44 uid = uidtool.register(photo)
45 return '%s %s' % (uid, photo.absolute_url())