--- a/src/pyams_content/site.py Fri Oct 12 14:33:03 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-
-__docformat__ = 'restructuredtext'
-
-import transaction
-from ZODB.interfaces import IBroken
-from hypatia.interfaces import ICatalog
-from zope.interface import Interface
-from zope.intid.interfaces import IIntIds
-
-from pyams_utils.container import find_objects_providing
-from pyams_utils.registry import set_local_registry, get_utility
-from pyams_utils.site import site_factory
-
-
-def site_index(request):
- """Index all site contents in internal catalog"""
- application = site_factory(request)
- if application is not None:
- try:
- set_local_registry(application.getSiteManager())
- catalog = get_utility(ICatalog)
- catalog.reset()
- transaction.savepoint()
- intids = get_utility(IIntIds)
- for index, document in enumerate(find_objects_providing(application, Interface)):
- if IBroken.providedBy(document):
- print("Skipping broken object: {0!r}".format(document))
- else:
- print("Indexing: {0!r}".format(document))
- catalog.reindex_doc(intids.register(document), document)
- if not index % 100:
- transaction.savepoint()
- finally:
- set_local_registry(None)
- transaction.commit()
- return application