## Script (Python) "reindex_entry_mode"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
# $Id: setEntryModeNewUME.py 1385 2007-02-01 20:43:29Z joachim $
"""
reindex students_catalog entry_mode index
"""
request = context.REQUEST
session = request.SESSION
response = request.RESPONSE
students = context.portal_url.getPortalObject().campus.students
def rwrite(s):
response.setHeader('Content-type','text/html; charset=ISO-8859-15')
#response.setHeader('Content-length','%d' % (len(s)))
#response.setStatus('OK')
response.write(s)
cat = context.students_catalog
ems = cat.uniqueValuesFor('entry_mode')
rwrite("entry_mode values: %s
\n" % (str(ems)))
for em in ems:
res = cat(entry_mode = em)
rwrite("entry_mode: %s = %d
\n" % (em,len(res)))
ume_100 = cat(entry_mode = 'None', level = '100')
rwrite("entry_mode (100): %s = %d
\n" % ('None',len(ume_100)))
de_100 = cat(entry_mode = 'DE', level = '100')
rwrite("entry_mode (100): %s = %d
\n" % ('DE',len(de_100)))
##from Products.zdb import set_trace;set_trace()
count = 0
lc = 1
for s in ume_100:
student = getattr(students,s.id,None)
if s is None:
rwrite('X')
continue
cat.modifyRecord(id = s.id, entry_mode='UME')
ec = 'C'
app = getattr(student,'application',None)
if app is not None:
app.getContent().edit(mapping={'entry_mode': "UME"})
ec = 'A'
rwrite(ec)
count += 1
if count > 60:
lc += 1
rwrite("
\n%3d " % lc)
count = 0