source: products/quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/content/vocabularies.py @ 2404

Last change on this file since 2404 was 2404, checked in by mylan, 14 years ago

#131: use default plone.app.vocabularies.ReallyUserFriendlyTypes? vocabulary for list allowable portal tyeps. Create new portal types vocabulary sceleton for associate portal type name to it's type-interface

  • Property svn:eol-style set to native
File size: 832 bytes
Line 
1from zope.app.schema.vocabulary import IVocabularyFactory
2from zope.interface import implements
3from zope.schema.vocabulary import SimpleVocabulary
4from zope.schema.vocabulary import SimpleTerm
5from plone.app.vocabularies.types import BAD_TYPES
6
7from Products.CMFCore.utils import getToolByName
8
9
10class TypesWithInterfaceVocabulary(object):
11    implements(IVocabularyFactory)
12
13    def __call__(self, context):
14        context = getattr(context, 'context', context)
15        ttool = getToolByName(context, 'portal_types', None)
16        if ttool is None:
17            return None
18        items = [ SimpleTerm(t, t, ttool[t].Title())
19                  for t in ttool.listContentTypes()
20                  if t not in BAD_TYPES ]
21        return SimpleVocabulary(items)
22
23TypesWithInterfaceVocabularyFactory = TypesWithInterfaceVocabulary()
Note: See TracBrowser for help on using the repository browser.