[754] | 1 | from zope.schema.vocabulary import SimpleVocabulary |
---|
| 2 | |
---|
| 3 | from Products.PluginIndexes.FieldIndex import FieldIndex |
---|
| 4 | from Products.PluginIndexes.KeywordIndex import KeywordIndex |
---|
| 5 | from Products.PluginIndexes.DateIndex import DateIndex |
---|
| 6 | from Products.PluginIndexes.DateRangeIndex import DateRangeIndex |
---|
| 7 | from Products.CMFCore.utils import getToolByName |
---|
| 8 | |
---|
| 9 | SORT_INDICES = (FieldIndex, KeywordIndex, DateIndex, DateRangeIndex) |
---|
| 10 | #SORT_INDICES = ('DateIndex', 'DateRangeIndex', 'FieldIndex', 'KeywordIndex') |
---|
| 11 | def getSortIndices( context ): |
---|
| 12 | catalog = getToolByName(context, 'portal_catalog') |
---|
| 13 | return SimpleVocabulary.fromValues( |
---|
| 14 | [k for k,v in catalog._catalog.indexes.items() if type(v) in SORT_INDICES]) |
---|
| 15 | |
---|
| 16 | def getPortalTypes( context ): |
---|
| 17 | pt = getToolByName(context, 'portal_types') |
---|
| 18 | return SimpleVocabulary.fromValues(pt.listContentTypes()) |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | def getPortalPath( context ): |
---|
| 22 | return getToolByName(context, 'portal_url').getPortalPath() |
---|
| 23 | |
---|
| 24 | def getWFStates( context ): |
---|
| 25 | pwf = getToolByName(context, 'portal_workflow') |
---|
| 26 | utokens = {} |
---|
| 27 | [utokens.update({k:v}) for k,v in pwf.listWFStatesByTitle() if k not in utokens.keys()] |
---|
| 28 | return SimpleVocabulary.fromItems(utokens.items()) |
---|
| 29 | |
---|
| 30 | |
---|