def setUpIndices(test): site = hooks.getSite() if zope.component.interfaces.ISite.providedBy(site): sm = site.getSiteManager() sm['default']['workflow-relevant-oids'] = idx = SetIndex() sm.registerUtility(idx, IIndex, name='workflow-relevant-oids') sm['default']['workitem-contributor'] = idx = SetIndex() sm.registerUtility(idx, IIndex, name='workitem-contributors') sm['default']['workitem-processid'] = idx = ValueIndex() sm.registerUtility(idx, IIndex, name='workitem-processid') sm['default']['worklist-value'] = idx = ValueIndex() sm.registerUtility(idx, IIndex, name='worklist-value') else: zope.component.provideUtility(SetIndex(), IIndex, name='workflow-relevant-oids') zope.component.provideUtility(SetIndex(), IIndex, name='workitem-contributors') zope.component.provideUtility(ValueIndex(), IIndex, name='workitem-processid') zope.component.provideUtility(ValueIndex(), IIndex, name='worklist-value')
def createBibliographyIndices(site): """ Create indexes on the default site management container and register them as named utilities.""" sm = site.getSiteManager() default = sm['default'] author_field = default['author-field'] = FieldIndex() sm.registerUtility(author_field, IIndex, name='author-field') author_fulltext = default['author-fulltext'] = TextIndex() sm.registerUtility(author_fulltext, IIndex, name='author-fulltext') title_field = default['title-field'] = FieldIndex() sm.registerUtility(title_field, IIndex, name='title-field') title_fulltext = default['title-fulltext'] = TextIndex() sm.registerUtility(title_fulltext, IIndex, name='title-fulltext') year_set = default['year-set'] = SetIndex() sm.registerUtility(year_set, IIndex, name='year-set') origyear_set = default['origyear-set'] = SetIndex() sm.registerUtility(origyear_set, IIndex, name='origyear-set') if not default.has_key('any-fulltext'): any_fulltext = default['any-fulltext'] = TextIndex() sm.registerUtility(any_fulltext, IIndex, name='any-fulltext')
def evolve(context): """ create year-set and origyear-set indices """ # We moved the imports here because of getInfo which only takes # the __doc__ string in evolve. getInfo should not import # anything. import zope.interface import zope.component from zope.app.zopeappgenerations import getRootFolder from zope.app.generations.utility import findObjectsProviding from zope.app.component import hooks import zc.relation import zope.intid from quotationtool.quotation.interfaces import IQuotation from quotationtool.relation import load, dump from z3c.indexer.interfaces import IIndexer, IIndex from z3c.indexer.index import SetIndex from quotationtool.site.interfaces import IQuotationtoolSite root = getRootFolder(context) site = None for s in findObjectsProviding(root, IQuotationtoolSite): site = s break if site is None: raise Exception('No quotationtool site!') hooks.setSite(site) sm = site.getSiteManager() default = sm['default'] year_set = default['year-set'] = SetIndex() origyear_set = default['origyear-set'] = SetIndex() sm.registerUtility(origyear_set, IIndex, name='origyear-set') sm.registerUtility(year_set, IIndex, name='year-set') sm.unregisterUtility(component=default['year-field'], provided=IIndex, name='year-field') sm.unregisterUtility(component=default['year-value'], provided=IIndex, name='year-value') del default['year-field'] del default['year-value']
def setUpIndices(test): from z3c.indexer.interfaces import IIndex from z3c.indexer.index import SetIndex site = hooks.getSite() if zope.component.interfaces.ISite.providedBy(site): sm = site.getSiteManager() sm['default']['attribution-set'] = idx = SetIndex() sm.registerUtility(idx, IIndex, name='attribution-set') sm['default']['related-attribution-set'] = idx = SetIndex() sm.registerUtility(idx, IIndex, name='related-attribution-set') else: zope.component.provideUtility(SetIndex(), IIndex, name='attribution-set') zope.component.provideUtility(SetIndex(), IIndex, name='related-attribution-set')
def createWorkFlowContainer(event): site = event.object sm = site.getSiteManager() site['workflow'] = container = WorkFlowContainer() container['contributor'] = contributor = WorkList() sm.registerUtility(contributor, interfaces.IWorkList, name='contributor') dc = IWriteZopeDublinCore(contributor) dc.title = u"Contribution" dc.description = u"List of work items to be worked on by contributors." container['editor'] = editor = WorkList() sm.registerUtility(editor, interfaces.IWorkList, name='editor') dc = IWriteZopeDublinCore(editor) dc.title = u"Editorial Review" dc.description = u"List of work items to be reviewed by the site's editors." container['technicaleditor'] = technicaleditor = WorkList() sm.registerUtility(technicaleditor, interfaces.IWorkList, name='technicaleditor') dc = IWriteZopeDublinCore(technicaleditor) dc.title = u"Technical Review" dc.description = u"List of work items to be reviewed by the site's technical staff." container['script'] = script = WorkList() sm.registerUtility(script, interfaces.IWorkList, name='script') dc = IWriteZopeDublinCore(script) dc.title = u"Script" dc.description = u"List of work items generated by automatic scripts, e.g. database evolutions. Scripts usually create a huge bunch of items." sm['default']['workflow-relevant-oids'] = oids = SetIndex() sm.registerUtility(oids, IIndex, name='workflow-relevant-oids') sm['default']['workitem-contributor'] = contribs = SetIndex() sm.registerUtility(contribs, IIndex, name='workitem-contributors') sm['default']['workitem-processid'] = processid = ValueIndex() sm.registerUtility(processid, IIndex, name='workitem-processid') sm['default']['worklist-value'] = idx = ValueIndex() sm.registerUtility(idx, IIndex, name='worklist-value')
def createAttributionIndex(event): sm = event.object.getSiteManager() sm['default'][ATTRIBUTION_INDEX] = idx = SetIndex() sm.registerUtility(idx, IIndex, name=ATTRIBUTION_INDEX)
def evolve(context): """ evolve to categorization based on annotations """ # We moved the imports here because of getInfo which only takes # the __doc__ string in evolve. getInfo should not import # anything. import zope.interface import zope.component from zope.app.zopeappgenerations import getRootFolder from zope.app.generations.utility import findObjectsProviding from zope.app.component import hooks from quotationtool.site.interfaces import IQuotationtoolSite root = getRootFolder(context) site = None for s in findObjectsProviding(root, IQuotationtoolSite): site = s break if site is None: raise Exception('No quotationtool site!') hooks.setSite(site) sm = site.getSiteManager() default = sm['default'] from zope.intid.interfaces import IIntIds intids = zope.component.getUtility(IIntIds, context=site) from persistent.list import PersistentList from z3c.indexer.index import SetIndex from z3c.indexer.interfaces import IIndex from quotationtool.categorization import interfaces from quotationtool.categorization.attribution import ATTRIBUTION_INDEX from quotationtool.categorization.relatedattribution import RELATED_ATTRIBUTION_INDEX sm['default'][ATTRIBUTION_INDEX] = idx = SetIndex() sm.registerUtility(idx, IIndex, name=ATTRIBUTION_INDEX) sm['default'][RELATED_ATTRIBUTION_INDEX] = idx = SetIndex() sm.registerUtility(idx, IIndex, name=RELATED_ATTRIBUTION_INDEX) categories = site['categories'] # create __categories attribute setattr(categories, '_CategoriesContainer__categories', categories._newCategoriesData()) for catset in categories.values(): # create relation_indices attribute setattr(catset, 'relation_indices', []) for name, cat in catset.items(): # register category in categories container categories.addCategory(name, cat) # evolve to annotation based attribution for intid in cat.attribution: obj = intids.getObject(intid) attribution = interfaces.IAttribution(obj).attribute( cat.__name__) # delete integer based attributes of category delattr(cat, '_Attribution__attribution') # delete integer based attributes of category set delattr(catset, '_Attribution__attribution')
def evolve(context): """ create workflow components """ # We moved the imports here because of getInfo which only takes # the __doc__ string in evolve. getInfo should not import # anything. import zope.interface import zope.component from zope.app.zopeappgenerations import getRootFolder from zope.app.generations.utility import findObjectsProviding from zope.app.component import hooks from quotationtool.site.interfaces import IQuotationtoolSite root = getRootFolder(context) site = None for s in findObjectsProviding(root, IQuotationtoolSite): site = s break if site is None: raise Exception('No quotationtool site!') hooks.setSite(site) sm = site.getSiteManager() default = sm['default'] from zope.dublincore.interfaces import IWriteZopeDublinCore from quotationtool.workflow.container import WorkFlowContainer from quotationtool.workflow.worklist import WorkList from quotationtool.workflow import interfaces from z3c.indexer.index import SetIndex from z3c.indexer.interfaces import IIndex site['workflow'] = container = WorkFlowContainer() container['contributor'] = contributor = WorkList() sm.registerUtility(contributor, interfaces.IWorkList, name='contributor') dc = IWriteZopeDublinCore(contributor) dc.title = u"Contribution" dc.description = u"List of work items to be worked on by contributors." container['editor'] = editor = WorkList() sm.registerUtility(editor, interfaces.IWorkList, name='editor') dc = IWriteZopeDublinCore(editor) dc.title = u"Editorial Review" dc.description = u"List of work items to be reviewed by the site's editors." container['technicaleditor'] = technicaleditor = WorkList() sm.registerUtility(technicaleditor, interfaces.IWorkList, name='technicaleditor') dc = IWriteZopeDublinCore(technicaleditor) dc.title = u"Technical Review" dc.description = u"List of work items to be reviewed by the site's technical staff." container['script'] = script = WorkList() sm.registerUtility(script, interfaces.IWorkList, name='script') dc = IWriteZopeDublinCore(script) dc.title = u"Script" dc.description = u"List of work items generated by automatic scripts, e.g. database evolutions. Scripts usually create a huge bunch of items." sm['default']['workflow-relevant-oids'] = oids = SetIndex() sm.registerUtility(oids, IIndex, name='workflow-relevant-oids') sm['default']['workitem-contributor'] = contribs = SetIndex() sm.registerUtility(contribs, IIndex, name='workitem-contributors')