Introduction
openc.excludesearch is designed to make it possible for an administrator to easily mark content as being hidden to searches.
NB: Requires dm’s AdvancedQuery from http://www.dieter.handshake.de/pyprojects/zope/#AdvancedQuery
First off, install myself:
>>> self.addProduct("openc.excludesearch")
We set up an object that will show in searches for “foo”:
>>> self.folder.invokeFactory('Document', 'foo', 'Foo Page')
'foo'
>>> self.folder['foo']
<ATDocument at .../foo>
>>> self.folder['foo'].setText("I am a foo object from foosville.")
We name it foo for convenience:
>>> foo = self.folder['foo']
We can see its text fine:
>>> foo.getText() '<p>I am a foo object from foosville.</p>' >>> foo.reindexObject()
If we search for it, we find it:
>>> app.plone.restrictedTraverse("queryCatalog")({"SearchableText":"foo"})
[<Products.ZCatalog.Catalog.mybrains object at ...>]
Once we activate the hiding functionality we don’t:
>>> foo.getField('hidesearch').get(foo)
False
>>> foo.getField('hidesearch').set(foo, value=True)
>>> foo.reindexObject()
>>> foo.getField('hidesearch').get(foo)
True
>>> app.plone.restrictedTraverse("queryCatalog")({"SearchableText":"foo"})
[]
This is because it has a new marker interface:
>>> from openc.excludesearch.interfaces import IExcludeFromSearch >>> IExcludeFromSearch(foo) <ATDocument at .../foo>
If we remove this marker, we find it again:
>>> foo.getField('hidesearch').get(foo)
True
>>> foo.getField('hidesearch').set(foo, value=False)
>>> foo.reindexObject()
>>> foo.getField('hidesearch').get(foo)
False
>>> app.plone.restrictedTraverse("queryCatalog")({"SearchableText":"foo"})
[<Products.ZCatalog.Catalog.mybrains object at ...>]
As we no longer provide that interface:
>>> IExcludeFromSearch(foo)
Traceback (most recent call last):
...
TypeError: ('Could not adapt', <ATDocument at .../foo>, <InterfaceClass openc.excludesearch.interfaces.IExcludeFromSearch>)
Todo
Subclass/monkeypatch collections so they know to ignore things with the IExcludeFromSearch marker interface
Changelog
0.1 - Unreleased
Doctest [MatthewWilkes]
Added an adapter for archetypes.schemaextended to add a boolean field to the settings schema of any AT content type that adds/removes the marker interface when used. [MatthewWilkes]
Customised the queryCatalog script in a skin layer to drop all results providing IExludeFromSearch using AdvancedQuery [MatthewWilkes]
Added a marker interface called IExcludeFromSearch [MatthewWilkes]
Release files for openc.excludesearch 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openc.excludesearch-0.1.1.tar.gz | 11.8 kB | Details |
Release files / openc.excludesearch-0.1.1.tar.gz
| Download URL | openc.excludesearch-0.1.1.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
866e0216266d335f1ede7b0137d6ec38d7e8434a96ad46870de4d880569c7f54
|
|
BLAKE2b-256 checksum How to use checksums |
4bc055ef4fc44e8ef1f1510fc125b28e0c77547851e0bc1e274e698179ef5fe2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |