r13814 - in Products.ATVocabularyManager/trunk: . Products/ATVocabularyManager/types/vdex
"hpeteragitator" <[email protected]> Tue, 27 Sep 2011 14:22:30 +0000
| Newsgroups | gmane.comp.web.zope.plone.archetypes.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: hpeteragitator
Date: Tue Sep 27 14:22:29 2011
New Revision: 13814
Modified:
Products.ATVocabularyManager/trunk/CHANGES.txt
Products.ATVocabularyManager/trunk/Products/ATVocabularyManager/types/vdex/vocabularyxml.py
Log:
Refactored getDisplayList for vdex vocabularies, added 'showTermPath' and 'showLeafsOnly' for vdex vocabularies.
Modified: Products.ATVocabularyManager/trunk/CHANGES.txt
==============================================================================
--- Products.ATVocabularyManager/trunk/CHANGES.txt (original)
+++ Products.ATVocabularyManager/trunk/CHANGES.txt Tue Sep 27 14:22:29 2011
@@ -8,7 +8,17 @@
- Avoid breaking the import of *.zexp-files when an vocabularies don't exist
anymore, but instantiated object still exist in the import-file.
[WouterVH]
-
+
+- Added field 'showTermPath' for vdex vocabularies, to manually turn of the
+ term path. [jensens] [hpeteragitator]
+
+- Added field 'showLeafsOnly' for vdex vocabularies, to change if only the leaf
+ of the vocabulary tree can be selected. [jensens] [hpeteragitator]
+
+- Refactored getDisplayList for vdex vocabularies [jensens] [hpeteragitator]
+
+- Run i18ndude and updated german translations [hpeteragitator]
+
1.6.1 (2011-05-02)
------------------
Modified: Products.ATVocabularyManager/trunk/Products/ATVocabularyManager/types/vdex/vocabularyxml.py
==============================================================================
--- Products.ATVocabularyManager/trunk/Products/ATVocabularyManager/types/vdex/vocabularyxml.py (original)
+++ Products.ATVocabularyManager/trunk/Products/ATVocabularyManager/types/vdex/vocabularyxml.py Tue Sep 27 14:22:29 2011
@@ -28,6 +28,8 @@
from zope.interface import implements
from imsvdex.vdex import VDEXManager, VDEXError
+from Products.ATContentTypes import ATCTMessageFactory as _
+
IMSVDEXVocabularySchema = Schema((
StringField(
@@ -37,7 +39,7 @@
default = '',
accessor = 'Title',
widget = StringWidget(
- label_msgid = 'label_title',
+ label=_(u'label_title', default=u'Title'),
visible = {'view': 'invisible', 'edit': 'invisible'},
i18n_domain = 'plone',
),
@@ -50,10 +52,8 @@
schemata = 'default',
widget = TextAreaWidget(
visible = {'view': 'visible', 'edit': 'invisible'},
- label = 'Description',
- description = "A short summary of the content",
- label_msgid = "label_description",
- description_msgid = "help_description",
+ label=_(u'label_description', default=u'Description'),
+ description=_(u'help_description', default=u'A short summary of the content'),
i18n_domain = "plone"),
),
@@ -61,20 +61,33 @@
name = 'vdex',
allowable_content_types = ["text/xml"],
widget = FileWidget(
- label = "VDEX-XML-Data",
- label_msgid = 'IMSVDEXVocabulary_label_vdex',
- description = "upload the IMS Vocabulary Definition Format "
- "compliant XML file into this text field.",
- description_msgid = 'IMSVDEXVocabulary_description_vdex',
- i18n_domain = 'ATVocabularyManager',
+ label=_(u'IMSVDEXVocabulary_label_vdex', default=u'VDEX-XML-Data'),
+ description=_(u'IMSVDEXVocabulary_description_vdex',
+ default=u'upload the IMS Vocabulary Definition Format '
+ 'compliant XML file into this text field.'),
allow_file_upload = True,
),
default_output_type = "text/plain",
default_content_type = "text/xml"
),
+ BooleanField(
+ name = 'showTermPath',
+ default = True,
+ widget = BooleanWidget(
+ label=_(u'label_showTermPath', default=u'Show Term Path'),
+ visible = {'view': 'visible', 'edit': 'visible'},
+ ),
+ ),
+ BooleanField(
+ name = 'showLeafsOnly',
+ default = True,
+ widget = BooleanWidget(
+ label=_(u'label_showLeafsOnly', default=u'Show Leafs Only'),
+ visible = {'view': 'visible', 'edit': 'visible'},
+ ),
+ ),
))
-
class IMSVDEXVocabulary(BaseContent):
"""Content type for handling of VDEX compliant vocabulary.
"""
@@ -99,7 +112,6 @@
return manager
return manager.getVocabName()
-
security.declareProtected(permissions.View, 'getDisplayList')
def getDisplayList(self, instance):
""" returns an object of class DisplayList as defined in
@@ -108,7 +120,20 @@
The instance of the content class is given as parameter.
"""
dl = DisplayList()
- self._appendToDisplayList(dl, self.getVocabularyDict(instance), None)
+ tree = self.getVocabularyDict(instance)
+
+ def build_display_list(current, valueparent):
+ for key in current:
+ value, part = current[key]
+ if valueparent and self.getShowTermPath():
+ value = '%s → %s' % (valueparent, value)
+ leafs_only = self.getShowLeafsOnly()
+ is_leaf = part is None
+ if (is_leaf and leafs_only) or (not leafs_only):
+ dl.add(key, value)
+ build_display_list(part or {}, value)
+
+ build_display_list(tree, None)
return dl
def getVocabularyDict(self, instance):
@@ -202,26 +227,6 @@
lang = 'neutral'
return lang and lang[:2] or None
- security.declarePrivate('_appendToDisplayList')
- def _appendToDisplayList(self, displaylist, vdict, valueparent):
- """ append subtree to flat display list
- """
- if not vdict:
- return
- for key in vdict.keys():
- if type(vdict[key]) == type((1, 2)):
- value = vdict[key][0]
- subdict= vdict[key][1] or None
- else:
- value = vdict[key]
- subdict= None
- if valueparent:
- value = '%s - %s' % (valueparent, value)
- if not self.showLeafsOnly() or subdict:
- displaylist.add(key, value)
- if subdict:
- self._appendToDisplayList(displaylist, subdict, value)
-
def SearchableText(self):
"""dont find in live-search"""
return ''
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1