1 | ## Script (Python) "ti_64fc_resolve" |
---|
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: ti_64fc_resolve.py 3045 2008-01-25 09:14:17Z joachim $ |
---|
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','joachim'): |
---|
22 | return |
---|
23 | |
---|
24 | |
---|
25 | import logging |
---|
26 | import DateTime |
---|
27 | logger = logging.getLogger('Skins.ti_64fc_resolve') |
---|
28 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
29 | #aq_portal = context.portal_catalog_real.evalAdvancedQuery |
---|
30 | accommodation = context.portal_accommodation |
---|
31 | aq_accommodation = accommodation.evalAdvancedQuery |
---|
32 | #students_folder = context.portal_url.getPortalObject().campus.students |
---|
33 | |
---|
34 | request = context.REQUEST |
---|
35 | session = request.SESSION |
---|
36 | response = request.RESPONSE |
---|
37 | setheader = request.RESPONSE.setHeader |
---|
38 | def rwrite(s): |
---|
39 | response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
40 | response.write("%s<br>\n\r" % s) |
---|
41 | |
---|
42 | beds = aq_accommodation(Eq('student','')) |
---|
43 | bed_list = [bed.bed for bed in beds] |
---|
44 | logger.info("found %d with empty student" % len(bed_list)) |
---|
45 | d = {} |
---|
46 | d['student'] = accommodation.not_occupied |
---|
47 | for bed in bed_list: |
---|
48 | d['bed'] = bed |
---|
49 | accommodation.modifyRecord(**d) |
---|
50 | logger.info("modified %s " % bed) |
---|
51 | |
---|