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 | |
---|
1 | from zope.app.schema.vocabulary import IVocabularyFactory |
---|
2 | from zope.interface import implements |
---|
3 | from zope.schema.vocabulary import SimpleVocabulary |
---|
4 | from zope.schema.vocabulary import SimpleTerm |
---|
5 | from plone.app.vocabularies.types import BAD_TYPES |
---|
6 | |
---|
7 | from Products.CMFCore.utils import getToolByName |
---|
8 | |
---|
9 | |
---|
10 | class 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 | |
---|
23 | TypesWithInterfaceVocabularyFactory = TypesWithInterfaceVocabulary() |
---|
Note: See
TracBrowser
for help on using the repository browser.