From ed8a0bfdc8a80311c5dee3bb668865619406021d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Pin?= Date: Fri, 22 Oct 2010 20:48:14 +0200 Subject: [PATCH 1/1] =?utf8?q?Ajout=20du=20script=20de=20traitement=20des?= =?utf8?q?=20requ=C3=AAtes=20Lightroom.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/lrservice.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 skins/lrservice.py diff --git a/skins/lrservice.py b/skins/lrservice.py new file mode 100644 index 0000000..821bad1 --- /dev/null +++ b/skins/lrservice.py @@ -0,0 +1,45 @@ +##parameters= + +from Products.Plinn.utils import makeValidId +from Products.CMFCore.utils import getToolByName + +utool = getToolByName(context, 'portal_url') +portal = utool.getPortalObject() +uidtool = getToolByName(portal, 'portal_uidhandler') + +fg = context.REQUEST.form.get + +method = fg('method') + +if method == 'normaliseAndCreatePath' : + normalizedPath = [] + o = portal + path = fg('path', '').split('/') + for part in path : + validId = makeValidId(o, part, allow_dup=1) + if o.hasObject(validId) : + normalizedPath.append(validId) + o = o[validId] + else : + id = o.invokeFactory('Portfolio', validId, title=part) + o = o[id] + normalizedPath.append(id) + + return '/'.join(normalizedPath) + +elif method == 'uploadPhoto' : + path = fg('normalizedPath') + name = fg('fileName') + portfolio = portal.restrictedTraverse(path) + photoId = makeValidId(portfolio, name, allow_dup=1) + if portfolio.hasObject(photoId) : + photo = portfolio[photoId] + photo.manage_upload(fg('photo')) + else : + id = portfolio.invokeFactory('Photo', + photoId, + file=fg('photo'), + content_type='image/jpeg') + photo = portfolio[photoId] + uid = uidtool.register(photo) + return '%s %s' % (uid, photo.absolute_url()) -- 2.20.1