rer.solrpush 1.3.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. rer/solrpush/__init__.py +7 -0
  2. rer/solrpush/adapters/__init__.py +1 -0
  3. rer/solrpush/adapters/configure.zcml +13 -0
  4. rer/solrpush/adapters/file.py +52 -0
  5. rer/solrpush/adapters/rss_feed.py +28 -0
  6. rer/solrpush/behaviors/__init__.py +0 -0
  7. rer/solrpush/behaviors/configure.zcml +16 -0
  8. rer/solrpush/behaviors/solr_fields.py +41 -0
  9. rer/solrpush/browser/__init__.py +0 -0
  10. rer/solrpush/browser/configure.zcml +111 -0
  11. rer/solrpush/browser/controlpanel.py +96 -0
  12. rer/solrpush/browser/elevate_settings.py +35 -0
  13. rer/solrpush/browser/maintenance.py +476 -0
  14. rer/solrpush/browser/query_debug.py +12 -0
  15. rer/solrpush/browser/querybuilder.py +168 -0
  16. rer/solrpush/browser/scales.py +80 -0
  17. rer/solrpush/browser/static/.gitkeep +0 -0
  18. rer/solrpush/browser/static/dist/dev/main.js +58240 -0
  19. rer/solrpush/browser/static/dist/dev/main.js.map +180 -0
  20. rer/solrpush/browser/static/dist/prod/main.js +9604 -0
  21. rer/solrpush/browser/static/dist/prod/main.js.map +1 -0
  22. rer/solrpush/browser/static/javascripts/FacetsContainer/index.js +46 -0
  23. rer/solrpush/browser/static/javascripts/ProgressBar/index.js +40 -0
  24. rer/solrpush/browser/static/javascripts/ProgressBarContainer/index.js +66 -0
  25. rer/solrpush/browser/static/javascripts/index.js +14 -0
  26. rer/solrpush/browser/static/package.json +13 -0
  27. rer/solrpush/browser/static/styles.css +22 -0
  28. rer/solrpush/browser/static/styles.css.map +1 -0
  29. rer/solrpush/browser/static/styles.scss +27 -0
  30. rer/solrpush/browser/static/yarn.lock +1408 -0
  31. rer/solrpush/browser/templates/controlpanel_layout.pt +49 -0
  32. rer/solrpush/browser/templates/query_debug.pt +17 -0
  33. rer/solrpush/browser/templates/reindex_solr.pt +35 -0
  34. rer/solrpush/configure.zcml +81 -0
  35. rer/solrpush/indexer.py +120 -0
  36. rer/solrpush/interfaces/__init__.py +8 -0
  37. rer/solrpush/interfaces/adapter.py +13 -0
  38. rer/solrpush/interfaces/elevate.py +98 -0
  39. rer/solrpush/interfaces/layer.py +6 -0
  40. rer/solrpush/interfaces/queueprocessor.py +6 -0
  41. rer/solrpush/interfaces/settings.py +194 -0
  42. rer/solrpush/locales/README.rst +37 -0
  43. rer/solrpush/locales/__init__.py +0 -0
  44. rer/solrpush/locales/en/LC_MESSAGES/rer.solrpush.mo +0 -0
  45. rer/solrpush/locales/en/LC_MESSAGES/rer.solrpush.po +399 -0
  46. rer/solrpush/locales/it/LC_MESSAGES/rer.solrpush.mo +0 -0
  47. rer/solrpush/locales/it/LC_MESSAGES/rer.solrpush.po +399 -0
  48. rer/solrpush/locales/rer.solrpush.pot +402 -0
  49. rer/solrpush/locales/update.py +71 -0
  50. rer/solrpush/locales/update.sh +12 -0
  51. rer/solrpush/parser.py +211 -0
  52. rer/solrpush/permissions.zcml +18 -0
  53. rer/solrpush/profiles/default/actions.xml +21 -0
  54. rer/solrpush/profiles/default/browserlayer.xml +7 -0
  55. rer/solrpush/profiles/default/catalog.xml +4 -0
  56. rer/solrpush/profiles/default/controlpanel.xml +31 -0
  57. rer/solrpush/profiles/default/metadata.xml +8 -0
  58. rer/solrpush/profiles/default/registry/bundle.xml +25 -0
  59. rer/solrpush/profiles/default/registry/criteria.xml +55 -0
  60. rer/solrpush/profiles/default/registry/settings.xml +6 -0
  61. rer/solrpush/profiles/default/rolemap.xml +13 -0
  62. rer/solrpush/profiles/default/types/Document.xml +12 -0
  63. rer/solrpush/profiles/to_1100/componentregistry.xml +9 -0
  64. rer/solrpush/profiles/to_1100/metadata.xml +5 -0
  65. rer/solrpush/profiles/to_1300/controlpanel.xml +13 -0
  66. rer/solrpush/profiles/to_1300/registry.xml +5 -0
  67. rer/solrpush/profiles/uninstall/browserlayer.xml +7 -0
  68. rer/solrpush/profiles/uninstall/controlpanel.xml +21 -0
  69. rer/solrpush/profiles/uninstall/registry.xml +17 -0
  70. rer/solrpush/restapi/__init__.py +0 -0
  71. rer/solrpush/restapi/configure.zcml +8 -0
  72. rer/solrpush/restapi/services/__init__.py +0 -0
  73. rer/solrpush/restapi/services/configure.zcml +8 -0
  74. rer/solrpush/restapi/services/elevate_schema/__init__.py +0 -0
  75. rer/solrpush/restapi/services/elevate_schema/configure.zcml +14 -0
  76. rer/solrpush/restapi/services/elevate_schema/get.py +12 -0
  77. rer/solrpush/restapi/services/solr_search/__init__.py +0 -0
  78. rer/solrpush/restapi/services/solr_search/batch.py +129 -0
  79. rer/solrpush/restapi/services/solr_search/configure.zcml +14 -0
  80. rer/solrpush/restapi/services/solr_search/get.py +25 -0
  81. rer/solrpush/restapi/services/solr_search/solr_search_handler.py +86 -0
  82. rer/solrpush/setuphandlers.py +20 -0
  83. rer/solrpush/testing.py +161 -0
  84. rer/solrpush/tests/__init__.py +0 -0
  85. rer/solrpush/tests/docs/example.docx +0 -0
  86. rer/solrpush/tests/docs/example.ods +0 -0
  87. rer/solrpush/tests/docs/example.pdf +0 -0
  88. rer/solrpush/tests/docs/plone_logo.png +0 -0
  89. rer/solrpush/tests/test_behaviors.py +61 -0
  90. rer/solrpush/tests/test_elevate.py +124 -0
  91. rer/solrpush/tests/test_events.py +181 -0
  92. rer/solrpush/tests/test_image_tags.py +85 -0
  93. rer/solrpush/tests/test_maintenance.py +165 -0
  94. rer/solrpush/tests/test_querybuilder.py +272 -0
  95. rer/solrpush/tests/test_restapi_search.py +127 -0
  96. rer/solrpush/tests/test_search.py +177 -0
  97. rer/solrpush/tests/test_setup.py +67 -0
  98. rer/solrpush/tests/test_solr_interface.py +359 -0
  99. rer/solrpush/tests/test_tika.py +85 -0
  100. rer/solrpush/tests/test_vocabularies.py +113 -0
  101. rer/solrpush/upgrades.py +76 -0
  102. rer/solrpush/upgrades.zcml +86 -0
  103. rer/solrpush/utils/__init__.py +6 -0
  104. rer/solrpush/utils/solr_common.py +122 -0
  105. rer/solrpush/utils/solr_indexer.py +295 -0
  106. rer/solrpush/utils/solr_search.py +352 -0
  107. rer/solrpush/vocabularies.py +50 -0
  108. rer.solrpush-1.3.4-py3.10-nspkg.pth +1 -0
  109. rer.solrpush-1.3.4.dist-info/LICENSE.GPL +339 -0
  110. rer.solrpush-1.3.4.dist-info/LICENSE.rst +15 -0
  111. rer.solrpush-1.3.4.dist-info/METADATA +507 -0
  112. rer.solrpush-1.3.4.dist-info/RECORD +116 -0
  113. rer.solrpush-1.3.4.dist-info/WHEEL +5 -0
  114. rer.solrpush-1.3.4.dist-info/entry_points.txt +5 -0
  115. rer.solrpush-1.3.4.dist-info/namespace_packages.txt +1 -0
  116. rer.solrpush-1.3.4.dist-info/top_level.txt +1 -0
@@ -0,0 +1,7 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Init and utils."""
3
+
4
+ from zope.i18nmessageid import MessageFactory
5
+
6
+
7
+ _ = MessageFactory("rer.solrpush")
@@ -0,0 +1 @@
1
+ # -*- coding: utf-8 -*-
@@ -0,0 +1,13 @@
1
+ <configure
2
+ xmlns="http://namespaces.zope.org/zope"
3
+ i18n_domain="rer.solrpush">
4
+
5
+ <adapter
6
+ for="plone.app.contenttypes.interfaces.IFile"
7
+ provides="rer.solrpush.interfaces.adapter.IExtractFileFromTika"
8
+ factory=".file.FileExtractor"
9
+ />
10
+
11
+ <!-- RSS feed -->
12
+ <adapter factory=".rss_feed.SOLRFeedItem"/>
13
+ </configure>
@@ -0,0 +1,52 @@
1
+ # -*- coding: utf-8 -*-
2
+ from plone import api
3
+ from rer.solrpush.interfaces.adapter import IExtractFileFromTika
4
+ from zope.interface import implementer
5
+
6
+ try:
7
+ from collective.limitfilesizepanel.interfaces import ILimitFileSizePanel
8
+
9
+ HAS_LFSP = True
10
+ except ImportError:
11
+ HAS_LFSP = False
12
+
13
+ import logging
14
+
15
+ logger = logging.getLogger(__name__)
16
+
17
+
18
+ @implementer(IExtractFileFromTika)
19
+ class FileExtractor(object):
20
+ def __init__(self, context):
21
+ self.context = context
22
+
23
+ def maxfilesize(self):
24
+ max_size = 30
25
+ if HAS_LFSP:
26
+ try:
27
+ file_size = api.portal.get_registry_record(
28
+ "file_size", interface=ILimitFileSizePanel
29
+ )
30
+ if file_size:
31
+ max_size = file_size
32
+ except Exception:
33
+ pass # we use our default
34
+ return max_size * 1024 * 1024
35
+
36
+ def get_file_to_index(self):
37
+ """
38
+ """
39
+ file_obj = getattr(self.context, "file", None)
40
+ if not file_obj:
41
+ return None
42
+ max_size = self.maxfilesize()
43
+ if file_obj.getSize() > max_size:
44
+ logger.warning(
45
+ "Maximun file size reached (%s > %s) for %s %s",
46
+ file_obj.getSize(),
47
+ max_size,
48
+ self.context.absolute_url_path(),
49
+ file_obj.filename,
50
+ )
51
+ return None
52
+ return file_obj.data
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ from Products.CMFPlone.browser.syndication.adapters import BaseItem
3
+ from Products.CMFPlone.interfaces.syndication import IFeed
4
+ from Products.CMFPlone.interfaces.syndication import IFeedItem
5
+ from rer.solrpush.interfaces.adapter import ISolrBrain
6
+ from zope.component import adapter
7
+ from zope.interface import implementer
8
+
9
+
10
+ @implementer(IFeedItem)
11
+ @adapter(ISolrBrain, IFeed)
12
+ class SOLRFeedItem(BaseItem):
13
+
14
+ @property
15
+ def link(self):
16
+ return self.context.getURL()
17
+
18
+ @property
19
+ def title(self):
20
+ return self.context.Title
21
+
22
+ @property
23
+ def description(self):
24
+ return self.context.Description
25
+
26
+ @property
27
+ def rights(self):
28
+ return ""
File without changes
@@ -0,0 +1,16 @@
1
+ <configure
2
+ xmlns="http://namespaces.zope.org/zope"
3
+ xmlns:plone="http://namespaces.plone.org/plone"
4
+ xmlns:zcml="http://namespaces.zope.org/zcml"
5
+ i18n_domain="rer.solrpush">
6
+
7
+ <include package="plone.behavior" file="meta.zcml"/>
8
+
9
+ <plone:behavior
10
+ title="Solr additional fields"
11
+ description="Extra fields for Solr indexing"
12
+ provides=".solr_fields.ISolrFields"
13
+ for="plone.dexterity.interfaces.IDexterityContent"
14
+ />
15
+
16
+ </configure>
@@ -0,0 +1,41 @@
1
+ # -*- coding: utf-8 -*-
2
+ from plone.autoform.interfaces import IFormFieldProvider
3
+ from plone.supermodel import directives
4
+ from plone.supermodel import model
5
+ from rer.solrpush import _
6
+ from zope import schema
7
+ from zope.interface import provider
8
+
9
+
10
+ @provider(IFormFieldProvider)
11
+ class ISolrFields(model.Schema):
12
+ """Additional fields to control Solr integration"""
13
+
14
+ directives.fieldset(
15
+ "categorization", fields=["showinsearch", "searchwords"]
16
+ )
17
+
18
+ showinsearch = schema.Bool(
19
+ required=False,
20
+ default=True,
21
+ missing_value=True,
22
+ title=_("label_showinsearch", default=u"Show in search"),
23
+ description=_("help_showinsearch", default=""),
24
+ )
25
+
26
+ searchwords = schema.List(
27
+ required=False,
28
+ default=[],
29
+ missing_value=[],
30
+ title=_("label_searchwords", default=u"Search words"),
31
+ value_type=schema.TextLine(),
32
+ description=_(
33
+ "help_searchwords",
34
+ u"Specify words for which this item will show up "
35
+ u"as the first search result. Multiple words can be "
36
+ u"specified on new lines.",
37
+ ),
38
+ )
39
+
40
+
41
+ # EOF
File without changes
@@ -0,0 +1,111 @@
1
+ <configure
2
+ xmlns="http://namespaces.zope.org/zope"
3
+ xmlns:browser="http://namespaces.zope.org/browser"
4
+ xmlns:plone="http://namespaces.plone.org/plone"
5
+ i18n_domain="rer.solrpush">
6
+
7
+ <plone:static
8
+ name="rer.solrpush"
9
+ type="plone"
10
+ directory="static"
11
+ />
12
+
13
+ <!-- controlpanel -->
14
+ <browser:page
15
+ name="solrpush-settings"
16
+ for="Products.CMFPlone.interfaces.IPloneSiteRoot"
17
+ class=".controlpanel.RerSolrpushSettingsView"
18
+ permission="rer.solrpush.editSettings"
19
+ layer="rer.solrpush.interfaces.IRerSolrpushLayer"
20
+ />
21
+ <browser:page
22
+ name="elevate-settings"
23
+ for="Products.CMFPlone.interfaces.IPloneSiteRoot"
24
+ class=".elevate_settings.ElevateSettingsView"
25
+ permission="rer.solrpush.editElevate"
26
+ layer="rer.solrpush.interfaces.IRerSolrpushLayer"
27
+ />
28
+
29
+ <browser:page
30
+ for="Products.CMFCore.interfaces.ISiteRoot"
31
+ name="reindex-solr"
32
+ permission="cmf.ManagePortal"
33
+ class=".maintenance.ReindexSolrView"
34
+ template="templates/reindex_solr.pt"
35
+ layer="rer.solrpush.interfaces.IRerSolrpushLayer"
36
+ />
37
+ <browser:page
38
+ for="Products.CMFCore.interfaces.ISiteRoot"
39
+ name="sync-solr"
40
+ permission="cmf.ManagePortal"
41
+ class=".maintenance.SyncSolrView"
42
+ template="templates/reindex_solr.pt"
43
+ layer="rer.solrpush.interfaces.IRerSolrpushLayer"
44
+ />
45
+
46
+ <browser:page
47
+ for="Products.CMFCore.interfaces.ISiteRoot"
48
+ name="reindex-progress"
49
+ permission="cmf.ManagePortal"
50
+ class=".maintenance.ReindexProgressView"
51
+ layer="rer.solrpush.interfaces.IRerSolrpushLayer"
52
+ />
53
+ <browser:page
54
+ for="Products.CMFCore.interfaces.ISiteRoot"
55
+ name="do-reindex"
56
+ permission="cmf.ManagePortal"
57
+ class=".maintenance.DoReindexView"
58
+ layer="rer.solrpush.interfaces.IRerSolrpushLayer"
59
+ />
60
+ <browser:page
61
+ for="Products.CMFCore.interfaces.ISiteRoot"
62
+ name="do-sync"
63
+ permission="cmf.ManagePortal"
64
+ class=".maintenance.DoSyncView"
65
+ layer="rer.solrpush.interfaces.IRerSolrpushLayer"
66
+ />
67
+
68
+ <browser:page
69
+ for="Products.CMFCore.interfaces.ISiteRoot"
70
+ name="reset-solr"
71
+ permission="cmf.ManagePortal"
72
+ class=".maintenance.ResetSolr"
73
+ layer="rer.solrpush.interfaces.IRerSolrpushLayer"
74
+ />
75
+
76
+ <!-- return scaled image -->
77
+ <browser:page
78
+ name="solr-images"
79
+ class=".scales.SolrImages"
80
+ permission="zope2.View"
81
+ for="*"
82
+ layer="rer.solrpush.interfaces.IRerSolrpushLayer"
83
+ />
84
+
85
+ <!-- CUSTOM COLLECTIONS -->
86
+ <browser:page
87
+ name="querybuilderresults"
88
+ class=".querybuilder.QueryBuilder"
89
+ permission="zope2.View"
90
+ for="*"
91
+ layer="rer.solrpush.interfaces.IRerSolrpushLayer"
92
+ />
93
+ <browser:page
94
+ name="querybuilder_html_results"
95
+ class=".querybuilder.QueryBuilder"
96
+ permission="zope2.View"
97
+ attribute="html_results"
98
+ for="*"
99
+ layer="rer.solrpush.interfaces.IRerSolrpushLayer"
100
+ />
101
+
102
+ <browser:viewlet
103
+ name="solrpush.querydebug"
104
+ manager="plone.app.layout.viewlets.interfaces.IBelowContent"
105
+ class=".query_debug.QueryDebug"
106
+ permission="cmf.ManagePortal"
107
+ template="templates/query_debug.pt"
108
+ layer="rer.solrpush.interfaces.IRerSolrpushLayer"
109
+ />
110
+
111
+ </configure>
@@ -0,0 +1,96 @@
1
+ # -*- coding: utf-8 -*-
2
+ from plone import api
3
+ from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper
4
+ from plone.app.registry.browser.controlpanel import RegistryEditForm
5
+ from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
6
+ from rer.solrpush import _
7
+ from rer.solrpush.interfaces.settings import IRerSolrpushConf
8
+ from rer.solrpush.interfaces.settings import IRerSolrpushSearchConf
9
+ from rer.solrpush.interfaces.settings import IRerSolrpushSettings
10
+ from rer.solrpush.utils import init_solr_push
11
+ from z3c.form import button
12
+ from z3c.form import field
13
+ from z3c.form import group
14
+ from z3c.form.interfaces import HIDDEN_MODE
15
+
16
+ import logging
17
+
18
+ logger = logging.getLogger(__name__)
19
+
20
+
21
+ class FormDefault(group.Group):
22
+ label = _("settings_default_label", default=u"Settings")
23
+ fields = field.Fields(IRerSolrpushConf)
24
+
25
+
26
+ class FormSearch(group.Group):
27
+ label = _("settings_search_label", default=u"Search")
28
+ description = _(
29
+ "settings_search_help",
30
+ default=u"Use these settings to tweak search results.",
31
+ )
32
+ fields = field.Fields(IRerSolrpushSearchConf)
33
+
34
+
35
+ class RerSolrpushEditForm(RegistryEditForm):
36
+ """Nel form del pannello di controllo mettiamo anche le logiche per
37
+ il caricamento
38
+ """
39
+
40
+ schema = IRerSolrpushSettings
41
+ groups = (FormDefault, FormSearch)
42
+ label = _(u"Solr Push Configuration")
43
+
44
+ formErrorsMessage = _(
45
+ "settings_form_error",
46
+ default=u"Sono presenti degli errori, si prega di ricontrollare i dati inseriti",
47
+ )
48
+
49
+ def updateFields(self):
50
+ super(RerSolrpushEditForm, self).updateFields()
51
+ for form_group in self.groups:
52
+ if "ready" in form_group.fields:
53
+ form_group.fields["ready"].mode = HIDDEN_MODE
54
+
55
+ @button.buttonAndHandler(_("Save"), name=None)
56
+ def handleSave(self, action):
57
+ data, errors = self.extractData()
58
+ if errors:
59
+ self.status = self.formErrorsMessage
60
+ return
61
+ self.applyChanges(data)
62
+ api.portal.show_message(_(u"Changes saved."), request=self.request)
63
+ init_error = init_solr_push()
64
+ if init_error:
65
+ api.portal.show_message(
66
+ init_error, type="error", request=self.request
67
+ )
68
+ else:
69
+ api.portal.show_message(
70
+ _(u"Loaded schema.xml from SOLR"), request=self.request
71
+ )
72
+ self.request.response.redirect(self.request.getURL())
73
+
74
+ @button.buttonAndHandler(_("Cancel"), name="cancel")
75
+ def handleCancel(self, action):
76
+ super(RerSolrpushEditForm, self).handleCancel(self, action)
77
+
78
+ @button.buttonAndHandler(_("Reload schema.xml"), name="reload")
79
+ def handleReload(self, action):
80
+ data, errors = self.extractData()
81
+
82
+ init_error = init_solr_push()
83
+ if init_error:
84
+ api.portal.show_message(
85
+ init_error, type="error", request=self.request
86
+ )
87
+ else:
88
+ api.portal.show_message(
89
+ _(u"Reloaded schema.xml from SOLR"), request=self.request
90
+ )
91
+ self.request.response.redirect(self.request.getURL())
92
+
93
+
94
+ class RerSolrpushSettingsView(ControlPanelFormWrapper):
95
+ form = RerSolrpushEditForm
96
+ index = ViewPageTemplateFile("templates/controlpanel_layout.pt")
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+ from collective.z3cform.jsonwidget.browser.widget import JSONFieldWidget
3
+ from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper
4
+ from plone.app.registry.browser.controlpanel import RegistryEditForm
5
+ from Products.CMFPlone.resources import add_bundle_on_request
6
+ from rer.solrpush import _
7
+ from rer.solrpush.interfaces import IElevateSettings
8
+ from rer.solrpush.interfaces.elevate import IElevateRowSchema
9
+ from z3c.form import field
10
+
11
+
12
+ class ElevateSettingsEditForm(RegistryEditForm):
13
+
14
+ schema = IElevateSettings
15
+ label = _(
16
+ "solr_elevate_configuration_label",
17
+ default=u"Solr Push Elevate Configuration",
18
+ )
19
+
20
+ fields = field.Fields(IElevateSettings)
21
+ fields["elevate_schema"].widgetFactory = JSONFieldWidget
22
+
23
+ def updateWidgets(self):
24
+ """
25
+ """
26
+ super(ElevateSettingsEditForm, self).updateWidgets()
27
+ self.widgets["elevate_schema"].schema = IElevateRowSchema
28
+
29
+
30
+ class ElevateSettingsView(ControlPanelFormWrapper):
31
+ form = ElevateSettingsEditForm
32
+
33
+ def __call__(self):
34
+ add_bundle_on_request(self.request, "z3cform-jsonwidget-bundle")
35
+ return super(ElevateSettingsView, self).__call__()