source: products/quintagroup.quills.extras/trunk/quintagroup/quills/extras/keywords_widget_patch.py @ 1239

Last change on this file since 1239 was 692, checked in by mylan, 17 years ago

preparing qPloneBlog package

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1from Products.AutocompleteWidget.AutocompleteWidget import AutocompleteWidget
2from Products.Archetypes import PloneMessageFactory as _
3from Products.CMFCore.utils import getToolByName
4from Products.Archetypes.utils import DisplayList
5from Products.ATContentTypes.content import schemata
6from Products.ATContentTypes.content.schemata import marshall_register
7from Products.ATContentTypes.content.schemata import ATContentTypeSchema
8from Products.ATContentTypes.content.base import ATCTMixin
9from Products.ATContentTypes.content.document import ATDocument
10from Products.ATContentTypes.content.folder import ATFolder, ATBTreeFolder
11from Products.ATContentTypes.content.image import ATImage
12from Products.ATContentTypes.content.event import ATEvent
13from Products.ATContentTypes.content.file import ATFile
14from Products.ATContentTypes.content.newsitem import ATNewsItem
15
16new_subject_widget = AutocompleteWidget(
17    label=_(u'label_categories', default = u'Categories'),
18    description=_(u'help_categories',
19                  default = u'Also known as keywords, tags or labels, '
20                           'these help you categorize your content.'),
21    actb_filter_bogus = 0,
22    actb_expand_onfocus = 0,
23    maxlength='1024'
24        )
25
26def getKeywords(self):
27    portal_catalog = getToolByName(self, 'portal_catalog')
28    res = portal_catalog.uniqueValuesFor('Subject')
29    return DisplayList(zip(res,res))
30
31ATCTMixin.getKeywords = getKeywords     
32
33for content_type in [ATFolder, ATDocument, ATBTreeFolder, ATImage, ATEvent, ATFile, ATNewsItem]:
34    content_type.schema['subject'].widget = new_subject_widget
35    content_type.schema['subject'].vocabulary = 'getKeywords'
36   
Note: See TracBrowser for help on using the repository browser.