Index: WAeUP_SRP/trunk/Widgets.py
===================================================================
--- WAeUP_SRP/trunk/Widgets.py	(revision 276)
+++ WAeUP_SRP/trunk/Widgets.py	(revision 295)
@@ -1,6 +1,11 @@
 #-*- mode: python; mode: fold -*-
+
+from cgi import escape
+
 from Globals import InitializeClass
 ##from Products.CPSSchemas.Widget import CPSWidgetType
-from Products.CPSSchemas.BasicWidgets import CPSStringWidget, CPSEmailWidget
+from Products.CMFCore.utils import getToolByName
+from Products.CPSSchemas.BasicWidgets import CPSWidget, CPSStringWidget, CPSEmailWidget
+from Products.CPSSchemas.BasicWidgets import renderHtmlTag,CPSSelectWidget, CPSStringWidget
 from Products.CPSSchemas.ExtendedWidgets import CPSDateTimeWidget
 from Products.CPSSchemas.Widget import widgetRegistry
@@ -12,4 +17,93 @@
 
 from zLOG import LOG, DEBUG
+
+class CPSSelectWidgetForRecord(CPSSelectWidget): ###(
+    """Select widget. with record names"""
+    meta_type = 'Select Widget for Records'
+
+    field_types = ('CPS String Field',)
+    field_inits = ({'is_searchabletext': 1,},)
+
+    _properties = CPSSelectWidget._properties + (
+        {'id': 'record_id', 'type': 'string', 'mode': 'w',
+         'label': 'Record Id', 'is_required' : 1},
+        )
+
+    def render(self, mode, datastructure, **kw):
+        """Render in mode from datastructure."""
+        value = datastructure[self.getWidgetId()]
+        vocabulary = self._getVocabulary(datastructure)
+        portal = getToolByName(self, 'portal_url').getPortalObject()
+        cpsmcat = portal.translation_service
+        if mode == 'view':
+            if self.translated:
+                return escape(cpsmcat(vocabulary.getMsgid(value, value)).encode('ISO-8859-15', 'ignore'))
+            else:
+                return escape(vocabulary.get(value, value))
+        elif mode == 'edit':
+            html_widget_id = self.getHtmlWidgetId()
+            res = renderHtmlTag('select', 
+                                name='%s.%s:records' % (self.record_id,html_widget_id), 
+                                id=html_widget_id)
+            in_selection = 0
+            for k, v in vocabulary.items():
+                if self.translated:
+                    kw = {'value': k,
+                          'contents': cpsmcat(vocabulary.getMsgid(k, k)).encode('ISO-8859-15', 'ignore')
+                          }
+                else:
+                    kw = {'value': k, 'contents': v}
+                if value == k:
+                    kw['selected'] = 'selected'
+                    in_selection = 1
+                res += renderHtmlTag('option', **kw)
+            if value and not in_selection:
+                kw = {'value': value, 'contents': 'invalid: '+ str(value),
+                      'selected': 'selected'}
+                res += renderHtmlTag('option', **kw)
+            res += '</select>'
+            return res
+        raise RuntimeError('unknown mode %s' % mode)
+
+InitializeClass(CPSSelectWidgetForRecord)
+
+widgetRegistry.register(CPSSelectWidgetForRecord)
+
+###)
+
+class CPSStringWidgetForRecord(CPSStringWidget):
+    """String widget."""
+    meta_type = 'String Widget For Record'
+
+    field_types = ('CPS String Field',)
+    field_inits = ({'is_searchabletext': 1,},)
+    _properties = CPSStringWidget._properties + (
+        {'id': 'record_id', 'type': 'string', 'mode': 'w',
+         'label': 'Record Id', 'is_required' : 1},
+        )
+
+    def render(self, mode, datastructure, **kw):
+        """Render in mode from datastructure."""
+        value = datastructure[self.getWidgetId()]
+        if mode == 'view':
+            return escape(value)
+        elif mode == 'edit':
+            # XXX TODO should use an other name than kw !
+            # XXX change this everywhere
+            html_widget_id = self.getHtmlWidgetId()
+            kw = {'type': 'text',
+                  'id'  : html_widget_id,
+                  'name': '%s.%s:records' % (self.record_id,html_widget_id), 
+                  'value': escape(value),
+                  'size': self.display_width,
+                  }
+            if self.size_max:
+                kw['maxlength'] = self.size_max
+            return renderHtmlTag('input', **kw)
+        raise RuntimeError('unknown mode %s' % mode)
+
+InitializeClass(CPSStringWidgetForRecord)
+
+widgetRegistry.register(CPSStringWidgetForRecord)
 
 class StudentIdWidget(CPSStringWidget): ###(
