1 | ## Script (Python) "hall_allocation_list" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=student=None |
---|
8 | ##title= |
---|
9 | ## |
---|
10 | # $Id: hall_allocation_list.py 1271 2007-01-11 17:49:57Z joachim $ |
---|
11 | """ |
---|
12 | export hall_allocation_list |
---|
13 | """ |
---|
14 | request = context.REQUEST |
---|
15 | setheader = request.RESPONSE.setHeader |
---|
16 | pa = context.portal_accommodation |
---|
17 | scat = context.students_catalog |
---|
18 | st_schema = context.students_catalog.schema() |
---|
19 | #fields = list(st_schema) + ["bed",] |
---|
20 | fields = ("id", |
---|
21 | "name", |
---|
22 | "bed", |
---|
23 | "matric_no", |
---|
24 | "jamb_reg_no", |
---|
25 | "sex", |
---|
26 | "email", |
---|
27 | "phone", |
---|
28 | "faculty", |
---|
29 | "department", |
---|
30 | "course", |
---|
31 | "level", |
---|
32 | ) |
---|
33 | res_list = [] |
---|
34 | lines = [] |
---|
35 | lines.append(','.join(fields)) |
---|
36 | format = '"%(' + ')s","%('.join(fields) + ')s"' |
---|
37 | reserved = pa(hall=context.getId()) |
---|
38 | for bed in reserved: |
---|
39 | if bed.student == '': |
---|
40 | continue |
---|
41 | erg = scat(id=bed.student) |
---|
42 | if not erg: |
---|
43 | continue |
---|
44 | d = context.getFormattedStudentEntry(erg[0]) |
---|
45 | d['bed'] = bed.bed |
---|
46 | lines.append(format % d) |
---|
47 | #setheader('Content-type', 'text/x-cvs') |
---|
48 | #setheader('Content-type','application/vnd.ms-excel') |
---|
49 | setheader('Content-type','text/semicolon-seperated-values') |
---|
50 | setheader('Expires', 'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past |
---|
51 | setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1 |
---|
52 | setheader('Cache-Control', 'post-check=0,pre-check=0') |
---|
53 | setheader('Pragma', 'no-cache') # HTTP/1.0 |
---|
54 | return '\n'.join(lines) |
---|