icsemantic.catalog

Package platecom :: Package ontocatalog |
[hide private]
[frames] | no frames]

# Source Code for Package icsemantic.catalog

     1  """OntoCatalog
     2  """
     3
     4  from zope import component
     5  from zope import interface
     6  from Products.pluggablecatalog.interfaces import IQueryDefaults
     7
     8  from AccessControl import ModuleSecurityInfo
     9  from zope.i18nmessageid import MessageFactory
    10
    11  OntoCatalogMessageFactory = MessageFactory('icsemantic.catalog')
    12  ModuleSecurityInfo('icsemantic.catalog').declarePublic('OntoCagalogMessageFactory')
    13
    14
    15  #Import indexes
    16  from platecom.ontocatalog.indexes.related import RelatedIndex, \
    17      manage_addRelatedIndex, manage_addRelatedIndexForm
    18  from platecom.ontocatalog.indexes.synonym import SynonymIndex, \
    19      manage_addSynonymIndex, manage_addSynonymIndexForm
    20  from platecom.ontocatalog.indexes.translation import TranslationIndex, \
    21      manage_addTranslationIndex, manage_addTranslationIndexForm
    22
    23
    24 -def initialize(context):
    25      """Initialize the package"""
    26      import criteria
    27      register_fake_index(context)
    28      replace_catalog(context)
    29
    30
    31 -def _catalog_search_defaults(context, request, args):
    32      """Ignore the Language keyword when we are looking for translations
    33      or related content.
    34      """
    35      #When searching for translations or related content we don't want Language
    36      #filtering.
    37      nofilterkeys = ['SearchableRelatedText', 'SearchableTranslatedText',
    38                      'SearchableSynonymousText']
    39
    40      for index in nofilterkeys:
    41          if args.has_key(index) or request.has_key(index):
    42              return {'Language': 'all'}
    43
    44      return {}
    45
    46
    47 -def replace_catalog(context):
    48      """Make _catalog_search_defaults provide IQueryDefaults so
    49      pluggablecatalog uses it for the default search paramenters for all
    50      catalog searches.
    51      """
    52      interface.directlyProvides(_catalog_search_defaults, IQueryDefaults)
    53      component.provideUtility(_catalog_search_defaults)
    54
    55
    56 -def register_fake_index(context):
    57      """Register indexes"""
    58      context.registerClass(
    59          RelatedIndex,
    60          permission='Add Pluggable Index',
    61          constructors=(manage_addRelatedIndexForm,
    62                        manage_addRelatedIndex),
    63          icon='indexes/www/index.gif',
    64          visibility=None
    65      )
    66
    67      context.registerClass(
    68          SynonymIndex,
    69          permission='Add Pluggable Index',
    70          constructors=(manage_addSynonymIndexForm,
    71                        manage_addSynonymIndex),
    72          icon='indexes/www/index.gif',
    73          visibility=None
    74      )
    75
    76      context.registerClass(
    77          TranslationIndex,
    78          permission='Add Pluggable Index',
    79          constructors=(manage_addTranslationIndexForm,
    80                        manage_addTranslationIndex),
    81          icon='indexes/www/index.gif',
    82          visibility=None
    83      )
    84