| 1 | ## Script (Python) "reindex_entry_mode" |
|---|
| 2 | ##bind container=container |
|---|
| 3 | ##bind context=context |
|---|
| 4 | ##bind namespace= |
|---|
| 5 | ##bind script=script |
|---|
| 6 | ##bind subpath=traverse_subpath |
|---|
| 7 | ##parameters= |
|---|
| 8 | ##title= |
|---|
| 9 | ## |
|---|
| 10 | # $Id: setEntryModeNewUME.py 1385 2007-02-01 20:43:29Z joachim $ |
|---|
| 11 | """ |
|---|
| 12 | reindex students_catalog entry_mode index |
|---|
| 13 | """ |
|---|
| 14 | request = context.REQUEST |
|---|
| 15 | session = request.SESSION |
|---|
| 16 | response = request.RESPONSE |
|---|
| 17 | students = context.portal_url.getPortalObject().campus.students |
|---|
| 18 | def rwrite(s): |
|---|
| 19 | response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
|---|
| 20 | #response.setHeader('Content-length','%d' % (len(s))) |
|---|
| 21 | #response.setStatus('OK') |
|---|
| 22 | response.write(s) |
|---|
| 23 | |
|---|
| 24 | cat = context.students_catalog |
|---|
| 25 | ems = cat.uniqueValuesFor('entry_mode') |
|---|
| 26 | rwrite("entry_mode values: %s<br />\n" % (str(ems))) |
|---|
| 27 | for em in ems: |
|---|
| 28 | res = cat(entry_mode = em) |
|---|
| 29 | rwrite("entry_mode: %s = %d<br />\n" % (em,len(res))) |
|---|
| 30 | |
|---|
| 31 | ume_100 = cat(entry_mode = 'None', level = '100') |
|---|
| 32 | rwrite("entry_mode (100): %s = %d<br />\n" % ('None',len(ume_100))) |
|---|
| 33 | de_100 = cat(entry_mode = 'DE', level = '100') |
|---|
| 34 | rwrite("entry_mode (100): %s = %d<br />\n" % ('DE',len(de_100))) |
|---|
| 35 | ##from Products.zdb import set_trace;set_trace() |
|---|
| 36 | count = 0 |
|---|
| 37 | lc = 1 |
|---|
| 38 | for s in ume_100: |
|---|
| 39 | student = getattr(students,s.id,None) |
|---|
| 40 | if s is None: |
|---|
| 41 | rwrite('X') |
|---|
| 42 | continue |
|---|
| 43 | cat.modifyRecord(id = s.id, entry_mode='UME') |
|---|
| 44 | ec = 'C' |
|---|
| 45 | app = getattr(student,'application',None) |
|---|
| 46 | if app is not None: |
|---|
| 47 | app.getContent().edit(mapping={'entry_mode': "UME"}) |
|---|
| 48 | ec = 'A' |
|---|
| 49 | rwrite(ec) |
|---|
| 50 | count += 1 |
|---|
| 51 | if count > 60: |
|---|
| 52 | lc += 1 |
|---|
| 53 | rwrite("<br />\n%3d " % lc) |
|---|
| 54 | count = 0 |
|---|