Index: WAeUP_SRP/base/Widgets.py
===================================================================
--- WAeUP_SRP/base/Widgets.py	(revision 3435)
+++ WAeUP_SRP/base/Widgets.py	(revision 3436)
@@ -13,4 +13,5 @@
 from Products.CPSSchemas.BasicWidgets import renderHtmlTag,CPSSelectWidget, CPSStringWidget
 from Products.CPSSchemas.ExtendedWidgets import CPSDateTimeWidget
+from Products.CPSSchemas.Vocabulary import Vocabulary
 from Products.CPSSchemas.Widget import widgetRegistry
 from Products.CPSUtil.file import PersistableFileUpload
@@ -765,4 +766,115 @@
 
 widgetRegistry.register(StudyCourseWidget)
+###)
+
+class VocabularyOnTheFly: ###(
+    def __init__(self, tuples):
+        """a nonpersistent vocabulary (copy from CPSSchemas.Vocabulary.Vocabulary).
+        Allowed parameter syntaxes is:
+          - Vocabulary((('foo', "Foo", 'label_foo'), ('bar', "Bar", 'label_bar')))
+            Same as first with message ids (msgids) that can be used for i18n
+        """
+        l = []
+        d = {}
+        m = {}
+        # We suppose that initial vocabulary is sorted
+        # Vocabulary((('foo', "Foo", 'label_foo'), ('bar', "Bar", 'label_bar')))
+        for k, v, msgid in tuples:
+            l.append(k)
+            d[k] = v
+            m[k] = msgid
+        self._list = l
+        self._dict = d
+        self._msgids = m
+    
+    def __getitem__(self, key):
+        """Get a label for a key."""
+        return self._dict[key]
+
+    def get(self, key, default=None):
+        """Get a label for a key, default to None."""
+        try:
+            v = self._dict.get(key, default)
+        except TypeError:
+            # XXX temporary fix, don't know why sometime rendering try to do
+            # get([]) that returning a typeError
+            return ''
+        return v
+
+    def getMsgid(self, key, default=None):
+        """Get a msgid for a key, default to None."""
+        return self._msgids.get(key, default)
+
+    def has_key(self, key):
+        """Test if a key is present."""
+        return self._dict.has_key(key)
+
+    def keys(self):
+        """Get the ordered list of keys."""
+        return self._list[:]
+
+    def items(self):
+        """Get the ordered list of (key, value)."""
+        return [(key, self._dict.get(key)) for key in self._list]
+
+    def values(self):
+        """Get the ordered list of values."""
+        return [self._dict.get(key) for key in self._list]
+
+    def keysSortedBy(self, crit='id'):
+        """Return a keys list sorted on a criterium
+
+        Crit is one of 'id', 'label' or 'i18n'.
+        """
+
+        if crit == 'label':
+            l = [(x[1], x[0]) for x in self.items()]
+            l.sort()
+            return [x[1] for x in l]
+        elif crit == 'i18n':
+            portal = getToolByName(self, 'portal_url').getPortalObject()
+            cpsmcat = portal.translation_service
+            l = [(cpsmcat(self.getMsgid(key)).encode('ISO-8859-15', 'ignore'),
+                  key) for key in self.keys()]
+            l.sort()
+            return [x[1] for x in l]
+        else:
+            return self.keys()
+###)
+
+class ApplicationCourseWidget(CPSSelectWidget): ###(
+    """ ApplicationCourse Widget"""
+    meta_type = "Application Course Widget"
+
+    def _getVocabulary(self,datastructure=None):
+        if self.REQUEST.traverse_subpath:
+            screening_type = self.REQUEST.traverse_subpath[0].upper()
+        else:
+            screening_type = 'ALL'
+        if screening_type in ("ALL","CEST","SANDWICH"):
+            application_category = screening_type
+        else:
+            application_category = "BASIC"
+        if not hasattr(self,'_v_certificates_docs'):
+            res = self.portal_catalog_real.search({'meta_type': "Certificate"})
+            d = {}
+            for cert in res:
+                c = cert.getObject().getContent()
+                if getattr(c,'application_category',''):
+                    d[cert.getId] = c
+            self._v_certificates_docs = d
+        l  = []
+        for k,d in self._v_certificates_docs.items():
+            if application_category == "ALL":
+                l  += (k,self._v_certificates_docs[k].title,k),
+            else:
+                if getattr(d,'application_category','') == application_category:
+                    l  += (k,self._v_certificates_docs[k].title,k),
+        #import ipdb;ipdb.set_trace()
+        return VocabularyOnTheFly(l)
+                                        
+InitializeClass(ApplicationCourseWidget)
+
+widgetRegistry.register(ApplicationCourseWidget)
 ###)
 
Index: WAeUP_SRP/base/skins/waeup_utilities/fillApplicationCategory.py
===================================================================
--- WAeUP_SRP/base/skins/waeup_utilities/fillApplicationCategory.py	(revision 3436)
+++ WAeUP_SRP/base/skins/waeup_utilities/fillApplicationCategory.py	(revision 3436)
@@ -0,0 +1,65 @@
+## Script (Python) "ti_507_resolve"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+"""
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+
+mtool = context.portal_membership
+member = mtool.getAuthenticatedMember()
+if str(member) not in ('admin','joachim'):
+    return
+
+import logging
+import DateTime
+logger = logging.getLogger('Skins.fillApplicationCategory')
+from Products.AdvancedQuery import Eq, Between, Le,In
+#aq_students = context.students_catalog.evalAdvancedQuery
+aq_portal = context.portal_catalog_real.evalAdvancedQuery
+#students_folder = context.portal_url.getPortalObject().campus.students
+
+request = context.REQUEST
+session = request.SESSION
+response = request.RESPONSE
+setheader = request.RESPONSE.setHeader
+logger.info('start')
+count = 0
+found = 0
+commit_after = 1000
+#certificates = context.getCertificatesDict()
+certificates = context.portal_catalog.search({'meta_type': "Certificate"})
+logger.info("found %d certificates" % len(certificates))
+cat = {'cos': 'BASIC',
+       'cos_cest': 'CEST',
+       'cos_sandwich': 'SANDWICH',
+       }
+to_change = {}
+for cert in certificates:
+    found = []
+    for v in ('cos','cos_cest','cos_sandwich'):
+        voc = getattr(context.portal_vocabularies,v)
+        if cert.id in voc.keys():
+            found += v,
+    if found:
+        d = {}
+        d['application_category'] = cat[found[0]]
+        d['cert_doc'] = cert.getObject().getContent()
+        to_change[cert.id] = d
+        logger.info("%s in %s" % (cert.id,','.join(found)))
+        count += 1
+for cert,d in to_change.items():
+    d['cert_doc'].edit(mapping = d)
+    logger.info("set application_category of %s to %s" % 
+               (cert,d['application_category']))
+logger.info("found %d not in vocabularies" % count)
