Last change
on this file since 12407 was
3992,
checked in by Henrik Bettermann, 16 years ago
|
remove line feeds in per_address
|
File size:
1.1 KB
|
Rev | Line | |
---|
[3992] | 1 | ## Script (Python) "removeLinefeed" |
---|
| 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: removeLinefeed.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.removeLinefeed') |
---|
| 27 | students = context.students_catalog() |
---|
| 28 | counter = 0 |
---|
| 29 | for student in students: |
---|
| 30 | counter += 1 |
---|
| 31 | sid = student.id |
---|
| 32 | perm_address = student.perm_address |
---|
| 33 | if perm_address and '\n' in perm_address: |
---|
| 34 | try: |
---|
| 35 | perm_address_new = perm_address.replace('\n',' ') |
---|
| 36 | context.students_catalog.modifyRecord(id = sid, |
---|
| 37 | perm_address = perm_address_new) |
---|
| 38 | logger.info('%d: %s, %s' % (counter, sid, perm_address_new)) |
---|
| 39 | except: |
---|
| 40 | logger.info('%s failed' % (sid)) |
---|
| 41 | continue |
---|
| 42 | return 'finished!' |
---|
| 43 | |
---|
| 44 | |
---|
Note: See
TracBrowser for help on using the repository browser.