source: products/quintagroup.mobileextender/trunk/quintagroup/mobileextender/browser/vocabularies.py @ 1561

Last change on this file since 1561 was 754, checked in by piv, 17 years ago

copied from trunk

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1from zope.schema.vocabulary import SimpleVocabulary
2
3from Products.PluginIndexes.FieldIndex import FieldIndex
4from Products.PluginIndexes.KeywordIndex import KeywordIndex
5from Products.PluginIndexes.DateIndex import DateIndex
6from Products.PluginIndexes.DateRangeIndex import DateRangeIndex
7from Products.CMFCore.utils import getToolByName
8
9SORT_INDICES = (FieldIndex, KeywordIndex, DateIndex, DateRangeIndex)
10#SORT_INDICES = ('DateIndex', 'DateRangeIndex', 'FieldIndex', 'KeywordIndex')
11def 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
16def getPortalTypes( context ):
17    pt = getToolByName(context, 'portal_types')
18    return SimpleVocabulary.fromValues(pt.listContentTypes())
19
20
21def getPortalPath( context ):
22    return getToolByName(context, 'portal_url').getPortalPath()
23
24def 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
Note: See TracBrowser for help on using the repository browser.