# -*- encoding: utf-8 from Globals import InitializeClass from OFS.SimpleItem import SimpleItem from OFS.Folder import Folder from OFS.PropertyManager import PropertyManager from Products.CMFCore.utils import UniqueObject from AccessControl import ClassSecurityInfo from Products.CMFCore.utils import getToolByName from Products.SQICore.SQICore import SQICore from Products.SQICore.SQISessionManager import SQISessionManager from Products.SQICore.interfaces.SQIInterface import ISQIInterface from Products.SQICore.interfaces.SQIInterface import ISQISessionManager from zope.interface import implements from xml.dom.minidom import parseString class SQISessionManager(Folder, SQISessionManager): """ SQI session manager """ implements(ISQISessionManager) meta_type = 'SQISessionManager' id = 'sessionmanager' security = ClassSecurityInfo() security.declareObjectPublic() manage_options = Folder.manage_options def _doUserCheck(self, username, password): """ check username and password """ if self.acl_users.authenticate(username, password, None): return 1 return 0 InitializeClass(SQISessionManager) class SQITool(SQICore, PropertyManager, UniqueObject, Folder): """ Provides SQI interface """ implements(ISQIInterface) meta_type = 'SQITool' id = 'sqitool' security = ClassSecurityInfo() plone_tool = 1 toolicon = '../LeMill/skins/lemill/tool.gif' manage_options = Folder.manage_options def __init__(self): ssm = SQISessionManager() self._setObject(ssm.id, ssm) #SQICore.__init__(self) def _processQuery(self, sessID, queryID): """ start processing query """ sess = self._getSession(sessID) parser = None if sess._queryLanguage.lower() == 'vsql': from Products.SQICore.Parsers import VSQI as parser if sess._queryLanguage.lower() == 'keywords': from Products.SQICore.Parsers import Keywords as parser query = parser(self, sessID, queryID) query['Creator'] = query['getAuthor'] query['SearchableText'] = query['fulltext'] del query['getAuthor'] del query['fulltext'] if query['Creator'] == '': del query['Creator'] results = None if query.has_key('object_uid'): rc = getToolByName(self, 'reference_catalog') results = rc.lookupObject(query['object_uid']) print "-------------", results else: results = self._execQuery(sessID, query) sess.setResultSet(results, queryID) #formatted = self._formatResults(sessID, results) return results def _execQuery(self, sessID, query): """ executing query """ cat = None cat = self.portal_catalog results = cat.search(query) return results def getFormatterConf(self, rf): if rf == 'RSS': return {'timestamp': 'CreationDate', 'title': 'Title', 'intro': 'Description', 'channel_title': 'LeFork testlink', 'channel_link': getToolByName(self, 'portal_url')(), 'channel_desc': 'Channel description here', 'channel_generator': 'LeFork SQITool', 'channel_lang': 'en'} elif rf == 'SingleObject': return {} elif rf == 'Objecti': return {'timestamp': 'CreationDate', 'title': 'Title', 'modified': 'ModificationDate'} InitializeClass(SQITool)