Skip to content

Commit

Permalink
remove hard dependency on Archetypes
Browse files Browse the repository at this point in the history
fix typo

'searchwords' are not required and move fields to categorization

skip behavior test, if DX is not installed

fix tests
  • Loading branch information
tomgross committed Nov 20, 2016
1 parent d83c761 commit 17b7d42
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ Changelog
SolrResponse inherit from ZCatalog Lazy class.
[tomgross]

- Remove hard dependency on Archetypes
[tomgross]

- Implement ``searchwords`` and ``showinsearch`` as Dexterity behavior.
[tomgross]

6.0a1 (2016-10-11)
------------------
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@
install_requires=[
'Acquisition',
'DateTime',
'Products.Archetypes',
'Products.CMFCore',
'Products.CMFPlone >= 4.3.7',
'Products.GenericSetup',
'ZODB3',
'Zope2 >= 2.13',
'archetypes.schemaextender',
'collective.indexing >= 2.0a2',
'collective.js.showmore',
'lxml',
Expand Down
6 changes: 5 additions & 1 deletion src/collective/solr/behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class ISolrFields(model.Schema):
""" Social Media integration.
"""

directives.fieldset('categorization',)
directives.fieldset(
'categorization',
fields=['showinsearch', 'searchwords']
)

showinsearch = schema.Bool(
required=False,
Expand All @@ -23,6 +26,7 @@ class ISolrFields(model.Schema):
)

searchwords = schema.List(
required=False,
default=[],
missing_value=[],
title=_('label_searchwords', default=u"Search words"),
Expand Down
28 changes: 19 additions & 9 deletions src/collective/solr/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@

<i18n:registerTranslations directory="locales" />

<include package="archetypes.schemaextender" />
<include package="collective.indexing" />
<include package="plone.browserlayer" />
<include package="plone.app.registry" />
<include package="collective.js.showmore" />
<include package="plone.restapi" />

<include file="extender.zcml" />
<include file="profiles.zcml" />
<include file="upgrades.zcml" />

Expand All @@ -40,6 +38,11 @@


<configure zcml:condition="installed Products.Archetypes">

<!-- Schema extender -->
<include file="extender.zcml" />

<!-- Adder adapter for Archetypes-->
<adapter
factory=".indexer.DefaultAdder"
for="Products.Archetypes.interfaces.IBaseObject"
Expand All @@ -59,6 +62,20 @@
/>
</configure>
<configure zcml:condition="installed plone.dexterity">

<include package="plone.dexterity" file="meta.zcml" />
<include package="plone.dexterity" />

<!-- Schema extender as behavior -->
<plone:behavior
title="Solr extension"
description="Extra fields for Solr indexing"
provides=".behaviors.ISolrFields"
for="plone.dexterity.interfaces.IDexterityContent"
zcml:condition="installed plone.app.dexterity"
/>

<!-- Adder adapter for Dexterity -->
<adapter
factory=".indexer.DefaultAdder"
for="plone.dexterity.interfaces.IDexterityContent"
Expand Down Expand Up @@ -143,11 +160,4 @@

<include package="plone.behavior" file="meta.zcml" />

<plone:behavior
title="Solr extension"
description="Extra fields for Solr indexing"
provides=".behaviors.ISolrFields"
for="plone.dexterity.interfaces.IDexterityContent"
/>

</configure>
3 changes: 2 additions & 1 deletion src/collective/solr/extender.zcml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<configure xmlns="http://namespaces.zope.org/zope" i18n_domain="solr">

<include package="archetypes.schemaextender" />
<adapter factory=".extender.searchwords" name="searchwords" />
<adapter factory=".extender.showinsearch" name="showinsearch" />

<adapter
for="Products.ATContentTypes.interface.IATContentType"
for="Products.Archetypes.interfaces.IBaseObject"
name="collective.solr.SearchExtender"
provides="archetypes.schemaextender.interfaces.ISchemaExtender"
factory=".extender.SearchExtender" />
Expand Down
14 changes: 13 additions & 1 deletion src/collective/solr/tests/test_behavior.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
# -*- coding: utf-8 -*-
import pkg_resources
import unittest

from collective.solr.testing import LEGACY_COLLECTIVE_SOLR_INTEGRATION_TESTING
from collective.solr.behaviors import ISolrFields
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.dexterity.fti import DexterityFTI
from collective.solr.testing import activateAndReindex


try:
pkg_resources.get_distribution('plone.dexterity')
from plone.dexterity.fti import DexterityFTI
HAS_DX = True
except pkg_resources.DistributionNotFound:
HAS_DX = False


@unittest.skipUnless(HAS_DX, 'Dexterity not found! Skipping behavior tests.')
class BehaviorsTestCase(unittest.TestCase):

layer = LEGACY_COLLECTIVE_SOLR_INTEGRATION_TESTING

def setUp(self):
self.portal = self.layer['portal']
activateAndReindex(self.portal)
setRoles(self.portal, TEST_USER_ID, ['Manager'])

fti = DexterityFTI('My Dexterity Container')
Expand Down
7 changes: 3 additions & 4 deletions src/collective/solr/tests/test_linguaplone.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
from plone.app.testing import setRoles
from transaction import abort
from transaction import commit
from unittest import TestCase
from zope.component import getUtility


class LinguaTests(TestCase):
@unittest.skipUnless(HAS_LINGUAPLONE,
"LinguaPlone not installed. skipping")
class LinguaTests(unittest.TestCase):

layer = LEGACY_COLLECTIVE_SOLR_FUNCTIONAL_TESTING

Expand All @@ -43,8 +44,6 @@ def tearDown(self):
self.config.async = False
commit()

@unittest.skipIf(not HAS_LINGUAPLONE,
"LinguaPlone not installed. skipping")
def testLanguageSearch(self):
en = self.portal[self.portal.invokeFactory('Document', 'doc')]
en.update(title='some document', language='en')
Expand Down

0 comments on commit 17b7d42

Please sign in to comment.