Last change
on this file since 12407 was
3961,
checked in by Henrik Bettermann, 16 years ago
|
Widgets.admitOneStudent: entry_session and session must start with '0'
fixSessionKey.py: fix students_catalog, won't be used, because we will import fresh student data with session and entry_session columns. Only 08 students are affected.
|
File size:
1.5 KB
|
Rev | Line | |
---|
[3961] | 1 | ## Script (Python) "fixSessionKey" |
---|
| 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: fixSessionKey.py 3132 2008-02-08 21:10:38Z henrik $ |
---|
| 11 | """ |
---|
| 12 | """ |
---|
| 13 | try: |
---|
| 14 | from Products.zdb import set_trace |
---|
| 15 | except: |
---|
| 16 | def set_trace(): |
---|
| 17 | pass |
---|
| 18 | |
---|
| 19 | mtool = context.portal_membership |
---|
| 20 | member = mtool.getAuthenticatedMember() |
---|
| 21 | if str(member) not in ('admin'): |
---|
| 22 | return |
---|
| 23 | |
---|
| 24 | import logging |
---|
| 25 | import DateTime |
---|
| 26 | logger = logging.getLogger('Skins.fixSessionKey') |
---|
| 27 | students = context.students_catalog() |
---|
| 28 | |
---|
| 29 | counter = 0 |
---|
| 30 | for student in students: |
---|
| 31 | counter += 1 |
---|
| 32 | modified = False |
---|
| 33 | sid = student.id |
---|
| 34 | try: |
---|
| 35 | session = student.session |
---|
| 36 | entry_session = student.entry_session |
---|
| 37 | ls = len(session) |
---|
| 38 | les = len (entry_session) |
---|
| 39 | except: |
---|
| 40 | #logger.info('%s failed' % (sid)) |
---|
| 41 | continue |
---|
| 42 | if ls == 1: |
---|
| 43 | session = '0%c' % session |
---|
| 44 | modified = True |
---|
| 45 | if les == 1: |
---|
| 46 | entry_session = '0%c' % entry_session |
---|
| 47 | modified = True |
---|
| 48 | if entry_session == '98' and session.lstrip('0') == '8': |
---|
| 49 | modified = True |
---|
| 50 | entry_session = '08' |
---|
| 51 | if modified: |
---|
| 52 | context.students_catalog.modifyRecord(id = sid, |
---|
| 53 | session=session, |
---|
| 54 | entry_session=entry_session) |
---|
| 55 | logger.info('%d: %s, %s, %s' % (counter, sid, session, entry_session)) |
---|
| 56 | |
---|
| 57 | return 'finished!' |
---|
| 58 | |
---|
| 59 | |
---|
Note: See
TracBrowser for help on using the repository browser.