Le Jeudi 9 Juin 2005 10:51, Ralf Kraemer a �crit�:
> Hello List
>
> i found something strange in cps3.3.4
>
> after editing portal_vocabularies/subject_voc to my needs the are no more
> entrys for that vocabulary at the meta data view for my documents.
> After filling the msgid field in the vocabulary these items where shown in
> the drop down list . I think that the "Label" and "Msgid"  fields are
> exchanged

I already had this problem. (see 
http://lists.nuxeo.com/pipermail/cps-users/2005-May/001222.html )

It's because the code behind the form that allow you to modify vocabulary 
entries consider empty strings ('') as is. So when you set nothing in "Msgid" 
field the render of the metadata view show you a list of empty string.

A first solution consist to set a "Msgid" string for each vocabulary entry (or 
obliged the user to do so).

Another solution consist in modification of vocabulary-related code to 
consider empty string as None value, and then display the vocabulary id when 
no Msgid found.

I did the latter. Please find my modifications in enclosed diff file.

-- 

  Kev.
--- ./CPS_3.2.4/out_of_the_box_products/CPSDirectory/DirectoryVocabulary.py     2004-10-08 08:42:12.000000000 +0000
+++ ./CPS_3.2.4/modified_products/CPSDirectory/DirectoryVocabulary.py   2005-05-24 07:43:01.000000000 +0000
@@ -110,7 +110,8 @@
             label = self[key]
         except (KeyError, AttributeError):
             label = default
-        return "label_cpsdir_"+ self.id + "_" + label
+        ## Kev patch
+        return label

     security.declareProtected(View, 'keys')
     def keys(self):


--- ./CPS_3.2.4/out_of_the_box_products/CPSSchemas/BasicWidgets.py      2005-01-17 19:14:31.000000000 +0000
+++ ./CPS_3.2.4/modified_products/CPSShemas/BasicWidgets.py     2005-05-24 15:27:41.000000000 +0000
@@ -1013,18 +1013,33 @@
         cpsmcat = portal.Localizer.default
         if mode == 'view':
             if getattr(self, 'translated', None):
-                return escape(cpsmcat(vocabulary.getMsgid(value, value)).encode('ISO-8859-15', 'ignore'))
+                ## Kev Patch
+                msg_id = vocabulary.getMsgid(value, value)
+                if msg_id == None:
+                    msg_id = vocabulary.get(value)
+                return escape(cpsmcat(msg_id).encode('ISO-8859-15', 'ignore'))
+                ## End of Kev Patch
             else:
-                return escape(vocabulary.get(value, value))
+                ## Kev Patch
+                msg_id = vocabulary.getMsgid(value, value)
+                if msg_id == None:
+                    msg_id = vocabulary.get(value)
+                return escape(msg_id)
+                ## End of Kev Patch
         elif mode == 'edit':
             res = renderHtmlTag('select',
                                 name=self.getHtmlWidgetId())
             in_selection = 0
             for k, v in vocabulary.items():
                 if getattr(self, 'translated', None):
+                    ## Kev Patch
+                    msg_id = vocabulary.getMsgid(k, k)
+                    if msg_id == None:
+                        msg_id = v
                     kw = {'value': k,
-                          'contents': cpsmcat(vocabulary.getMsgid(k, k)).encode('ISO-8859-15', 'ignore')
+                          'contents': cpsmcat(msg_id).encode('ISO-8859-15', 'ignore')
                           }
+                    ## End of Kev Patch
                 else:
                     kw = {'value': k, 'contents': v}
                 if value == k:
@@ -1133,9 +1148,25 @@
                 return self.format_empty
             # XXX customize view mode, lots of displays are possible
             elif getattr(self, 'translated', None):
-                return ', '.join([escape(cpsmcat(vocabulary.getMsgid(i, i))) for i in value])
+                ## Kev Patch
+                value_list = []
+                for i in value:
+                    msg_id = vocabulary.getMsgid(i, i)
+                    if msg_id == None:
+                        msg_id = vocabulary.get(i)
+                    value_list.append(escape(cpsmcat(msg_id)))
+                return ', '.join(value_list)
+                ## End of Kev Patch
             else:
-                return ', '.join([escape(vocabulary.get(i, i)) for i in value])
+                ## Kev Patch
+                value_list = []
+                for i in value:
+                    msg_id = vocabulary.getMsgid(i, i)
+                    if msg_id == None:
+                        msg_id = vocabulary.get(i)
+                    value_list.append(escape(msg_id))
+                return ', '.join(value_list)
+                ## End of Kev Patch
         elif mode == 'edit':
             html_widget_id = self.getHtmlWidgetId()
             kw = {'name': html_widget_id+':list',
@@ -1146,9 +1177,14 @@
             res = renderHtmlTag('select', **kw)
             for k, v in vocabulary.items():
                 if getattr(self, 'translated', None):
+                    ## Kev Patch
+                    msg_id = vocabulary.getMsgid(k, k)
+                    if msg_id == None:
+                        msg_id = v
                     kw = {'value': k,
-                          'contents': cpsmcat(vocabulary.getMsgid(k, k)).encode('ISO-8859-15', 'ignore')
+                          'contents': cpsmcat(msg_id).encode('ISO-8859-15', 'ignore')
                           }
+                    ## End of Kev Patch
                 else:
                     kw = {'value': k, 'contents': v}
                 if k in value:


--- ./CPS_3.2.4/out_of_the_box_products/CPSSchemas/MethodVocabulary.py  2004-04-27 09:03:51.000000000 +0000
+++ ./CPS_3.2.4/modified_products/CPSShemas/MethodVocabulary.py 2005-05-24 07:34:45.000000000 +0000
@@ -101,7 +101,8 @@
     security.declareProtected(View, 'getMsgid')
     def getMsgid(self, key, default=None):
         # XXX dummy
-        return key+'msgid'
+        ## Kev Patch
+        return None

     security.declareProtected(View, 'keys')
     def keys(self):


--- ./CPS_3.2.4/out_of_the_box_products/CPSSchemas/Vocabulary.py        2004-09-21 09:43:45.000000000 +0000
+++ ./CPS_3.2.4/modified_products/CPSShemas/Vocabulary.py       2005-05-24 07:33:51.000000000 +0000
@@ -151,6 +151,10 @@
         if not self._dict.has_key(key):
             self._list.append(key)
         self._dict[key] = label
+        ## Kev Patch
+        if msgid == '':
+          msgid = None
+        ## End of Kev Patch
         self._msgids[key] = msgid

     def __getitem__(self, key):
_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel

Reply via email to