Last change
on this file since 5200 was
5200,
checked in by Henrik Bettermann, 15 years ago
|
add metadata (not indexes!) date_of_birth and marit_stat to students_catalog
fillMetadata.py: tool to fill metadata and/or reindex the students_catalog
|
-
Property svn:keywords set to
Id
|
File size:
1.4 KB
|
Line | |
---|
1 | ## Script (Python) "fillMetadata" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=REQUEST |
---|
8 | ##title= |
---|
9 | ## |
---|
10 | # $Id: fillMetadata.py 5200 2010-05-20 10:08:17Z henrik $ |
---|
11 | """ |
---|
12 | |
---|
13 | """ |
---|
14 | |
---|
15 | request = REQUEST |
---|
16 | wftool = context.portal_workflow |
---|
17 | mtool = context.portal_membership |
---|
18 | member = mtool.getAuthenticatedMember() |
---|
19 | roles = member.getRolesInContext(context) |
---|
20 | retcat = context.returning_import |
---|
21 | scat = context.students_catalog |
---|
22 | students_folder = context.portal_url.getPortalObject().campus.students |
---|
23 | if str(member) not in ('admin',): |
---|
24 | return |
---|
25 | count = 0 |
---|
26 | students = scat() |
---|
27 | #from Products.zdb import set_trace;set_trace() |
---|
28 | for sbrain in students: |
---|
29 | student = getattr(students_folder,sbrain.id,None) |
---|
30 | if student is None: |
---|
31 | continue |
---|
32 | |
---|
33 | |
---|
34 | per = getattr(student,'personal',None) |
---|
35 | if per is None: |
---|
36 | continue |
---|
37 | #from Products.zdb import set_trace;set_trace() |
---|
38 | marit_stat = per.getContent().marit_stat |
---|
39 | if marit_stat == True: |
---|
40 | ms = 'married' |
---|
41 | elif marit_stat == False: |
---|
42 | ms = 'single' |
---|
43 | else: |
---|
44 | ms = 'undefined' |
---|
45 | |
---|
46 | clear = getattr(student,'clearance',None) |
---|
47 | if clear is None: |
---|
48 | continue |
---|
49 | birthday = clear.getContent().birthday |
---|
50 | if birthday: |
---|
51 | bd = birthday |
---|
52 | else: |
---|
53 | bd = '' |
---|
54 | |
---|
55 | context.students_catalog.modifyRecord(id = sbrain.id,marit_stat = ms, date_of_birth = bd) |
---|
56 | return 'ready' |
---|
57 | |
---|
58 | |
---|
59 | |
---|
Note: See
TracBrowser for help on using the repository browser.