--- a/src/pyams_content/features/search/__init__.py Fri Dec 14 18:11:21 2018 +0100
+++ b/src/pyams_content/features/search/__init__.py Fri Dec 14 18:29:23 2018 +0100
@@ -9,31 +9,30 @@
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
-from pyams_content.shared.view.portlet import SEARCH_EXCLUDED_ITEMS
-
__docformat__ = 'restructuredtext'
from hypatia.interfaces import ICatalog
-from hypatia.query import Contains, Or, NotAny
+from hypatia.query import Contains, Eq, NotAny, Or
from zope.interface import implementer
from zope.schema.fieldproperty import FieldProperty
+from pyams_content import _
from pyams_content.component.illustration import IIllustrationTarget, ILinkIllustrationTarget
from pyams_content.features.preview.interfaces import IPreviewTarget
from pyams_content.features.search.interfaces import ISearchFolder, ISearchFolderRoles
from pyams_content.interfaces import GUEST_ROLE, MANAGER_ROLE, MANAGE_SITE_PERMISSION
from pyams_content.shared.view import IViewQuery, ViewQuery, WfView
from pyams_content.shared.view.interfaces import IViewUserQuery
+from pyams_content.shared.view.portlet import SEARCH_EXCLUDED_ITEMS
from pyams_form.interfaces.form import IFormContextPermissionChecker
from pyams_i18n.interfaces import INegotiator
from pyams_portal.interfaces import DESIGNER_ROLE, IPortalContext
+from pyams_sequence.interfaces import ISequentialIntIds
from pyams_utils.adapter import ContextAdapter, adapter_config
from pyams_utils.registry import get_utility
from pyams_utils.request import check_request
-from pyams_content import _
-
@implementer(ISearchFolder, ISearchFolderRoles, IIllustrationTarget, ILinkIllustrationTarget,
IPortalContext, IPreviewTarget)
@@ -122,14 +121,21 @@
fulltext = params.get('user_search')
if fulltext:
catalog = get_utility(ICatalog)
- negotiator = get_utility(INegotiator)
- query_params = []
- for lang in {request.registry.settings.get('pyramid.default_locale_name', 'en'),
- request.locale_name,
- negotiator.server_language} | negotiator.offered_languages:
- index_name = 'title:{0}'.format(lang)
- if index_name in catalog:
- index = catalog[index_name]
- if index.check_query(fulltext):
- query_params.append(Contains(index, ' and '.join((w + '*' for w in fulltext.split()))))
- yield Or(*query_params)
+ # check +oid in user query
+ if fulltext.startswith('+'):
+ sequence = get_utility(ISequentialIntIds)
+ oid = sequence.get_full_oid(fulltext)
+ yield Eq(catalog['oid'], oid)
+ else:
+ # check fulltext query
+ negotiator = get_utility(INegotiator)
+ query_params = []
+ for lang in {request.registry.settings.get('pyramid.default_locale_name', 'en'),
+ request.locale_name,
+ negotiator.server_language} | negotiator.offered_languages:
+ index_name = 'title:{0}'.format(lang)
+ if index_name in catalog:
+ index = catalog[index_name]
+ if index.check_query(fulltext):
+ query_params.append(Contains(index, ' and '.join((w + '*' for w in fulltext.split()))))
+ yield Or(*query_params)
--- a/src/pyams_content/shared/view/reference.py Fri Dec 14 18:11:21 2018 +0100
+++ b/src/pyams_content/shared/view/reference.py Fri Dec 14 18:29:23 2018 +0100
@@ -10,7 +10,6 @@
# FOR A PARTICULAR PURPOSE.
#
-
__docformat__ = 'restructuredtext'
from hypatia.catalog import CatalogQuery