This repository has been archived by the owner on May 13, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* A pipeline factory registry now allows registration of possible pipeline elements for use by Zope lexicons. * ZMI constructor form for lexicon uses pipeline registry to generate form fields * ZMI constructor form for ZCTextindex allows you to choose between Okapi and Cosine relevance algorithms
- Loading branch information
Showing
10 changed files
with
257 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2002 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.0 (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 | ||
# | ||
############################################################################## | ||
|
||
from Interface import Base as Interface | ||
|
||
class IPipelineElementFactory(Interface): | ||
"""Class for creating pipeline elements by name""" | ||
|
||
def registerFactory(name, factory): | ||
"""Registers a pipeline factory by name. | ||
Each name can be registered only once. Duplicate registrations | ||
will raise a ValueError | ||
""" | ||
|
||
def getFactoryNames(): | ||
"""Returns a sorted list of registered pipeline factory names | ||
""" | ||
|
||
def instantiate(name): | ||
"""Instantiates a pipeline element by name. If name is not registered | ||
raise a KeyError. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2002 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.0 (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 | ||
# | ||
############################################################################## | ||
|
||
from Products.ZCTextIndex.IPipelineElementFactory \ | ||
import IPipelineElementFactory | ||
|
||
class PipelineElementFactory: | ||
|
||
__implements__ = IPipelineElementFactory | ||
|
||
def __init__(self): | ||
self._elements = {} | ||
|
||
def registerFactory(self, name, factory): | ||
if self._elements.has_key(name): | ||
raise ValueError, 'ZCTextIndex splitter named' + \ | ||
'"%s" already registered' | ||
|
||
self._elements[name] = factory | ||
|
||
def getFactoryNames(self): | ||
names = self._elements.keys() | ||
names.sort() | ||
return names | ||
|
||
def instantiate(self, name): | ||
return self._elements[name]() | ||
|
||
|
||
splitter_factory = PipelineElementFactory() | ||
|
||
element_factory = PipelineElementFactory() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.