File: __init__.py

package info (click to toggle)
zope-textindexng2 1%3A2.2.0-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,888 kB
  • ctags: 1,598
  • sloc: ansic: 6,836; python: 6,596; xml: 185; makefile: 137; sh: 41
file content (94 lines) | stat: -rw-r--r-- 2,779 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
###########################################################################
#
# TextIndexNG                The next generation TextIndex for Zope
#
# This software is governed by a license. See
# LICENSE.txt for the terms of this license.
#
###########################################################################

# some ZCatalog monkey patching

import os, sys

if not sys.version_info > (2,3,3):
    raise RuntimeError('This version of TextIndexNG requires Python 2.3.3+')

package_home = os.path.dirname(__file__)
if not package_home in sys.path:
    sys.path.append(package_home)


def getEntriesFromRegistry(self, id):
    """ get infos from a TXNG registry """

    from Products.TextIndexNG2.Registry import LexiconRegistry
    from Products.TextIndexNG2.Registry import ConverterRegistry
    from Products.TextIndexNG2.Registry import NormalizerRegistry
    from Products.TextIndexNG2.Registry import ParserRegistry
    from Products.TextIndexNG2.Registry import SplitterRegistry
    from Products.TextIndexNG2.Registry import StopwordsRegistry
    from Products.TextIndexNG2.Registry import StorageRegistry
    from Products.TextIndexNG2.Registry import ThesaurusRegistry

    registry = None 

    try:
        registry = vars()['%sRegistry' % id]
    except:
        import traceback
        traceback.print_exc()
        raise

    keys = registry.allIds()
    keys.sort()
    return [(k, registry.getRegisteredObject(k)) for k in keys] 


try:
    import normalizer, indexsupport
except ImportError:
    from zLOG import LOG, ERROR
    LOG("TextIndexNG",ERROR,"Import of Python extensions failed")
    


def initialize(context):
    from Products.TextIndexNG2 import TextIndexNG

    manage_addTextIndexNGForm = TextIndexNG.manage_addTextIndexNGForm 
    manage_addTextIndexNG     = TextIndexNG.manage_addTextIndexNG
    
    context.registerClass( 
        TextIndexNG.TextIndexNG,
        permission='Add Pluggable Index', 
        constructors=(manage_addTextIndexNGForm,
        manage_addTextIndexNG),
        icon='www/index.gif',
        visibility=None
        )

    context.registerHelp()
    context.registerHelpTitle("Zope Help")

    from Products.ZCatalog.ZCatalog import ZCatalog
    ZCatalog.getEntriesFromRegistry = getEntriesFromRegistry

    import converters
    import thesaurus


# Indicate if we should omit register 2nd-level components
fast_startup = int(os.environ.get('TXNG_FASTSTARTUP', 0))

################################################################
# Register with CMF/Plone
################################################################

textindexng_globals = globals()

try:
    from Products.CMFCore.DirectoryView import registerDirectory
    registerDirectory('skins', textindexng_globals)
except ImportError:
    pass