From afd6dda3d1889df6ac322a9175efc80564fd2a8c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Sat, 28 Jun 2014 17:44:08 +0200 Subject: [PATCH] =?utf8?q?Ajout=20utilitaire=20pour=20mettre=20=C3=A0=20jo?= =?utf8?q?ur=20les=20dates=20de=20prise=20de=20vues=20(n=C3=A9cessaire=20s?= =?utf8?q?uite=20aux=20=C3=A9volutions=20de=20xmp=20/=20LR4-5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- _zctl/updateDateTimeOriginal.py | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 _zctl/updateDateTimeOriginal.py diff --git a/_zctl/updateDateTimeOriginal.py b/_zctl/updateDateTimeOriginal.py new file mode 100644 index 0000000..5e73cb8 --- /dev/null +++ b/_zctl/updateDateTimeOriginal.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +from argparse import ArgumentParser +import os +from AccessControl import getSecurityManager +from Testing.makerequest import makerequest +from zope.globalrequest import setRequest +from zope.site.hooks import setSite +from ZODB.POSException import ConflictError +import transaction + +def main(app, portal_path, userid) : + portal = app.unrestrictedTraverse(portal_path) + portal = makerequest(portal) + setRequest(portal.REQUEST) + setSite(portal) + user = portal.acl_users.getUser(userid) + sm = getSecurityManager() + sm._context.user = user + ctool = portal.portal_catalog + brains = ctool.unrestrictedSearchResults(portal_type='Photo', tiles_available=1) + + for i, brain in enumerate(brains) : + photo = brain.getObject() + print photo.absolute_url() + if photo._methodResultsCache.has_key('DateTimeOriginal') : + del photo._methodResultsCache['DateTimeOriginal'] + photo.reindexObject(idxs=['DateTimeOriginal']) + if i and i % 100 == 0 : + transaction.commit() + transaction.commit() + print 'Done.' + + +if __name__ == '__main__': + parser = ArgumentParser(description="Update DateTimeOriginal index") + parser.add_argument('portal_path', help='portal object path') + parser.add_argument('userid', help='zope user id') + args = parser.parse_args() + main(app, + args.portal_path, + args.userid) \ No newline at end of file -- 2.20.1