[3296] | 1 | ## Script (Python) "import_uploads" |
---|
| 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:import_uploads.py 486 2006-09-06 10:09:39Z joachim $ |
---|
| 11 | """ |
---|
| 12 | do the import for uploads |
---|
| 13 | """ |
---|
| 14 | try: |
---|
| 15 | from Products.zdb import set_trace |
---|
| 16 | except: |
---|
| 17 | def set_trace(): |
---|
| 18 | pass |
---|
| 19 | request = context.REQUEST |
---|
| 20 | import DateTime, logging |
---|
| 21 | from urllib import urlencode |
---|
| 22 | current = DateTime.DateTime() |
---|
| 23 | pr = context.portal_registration |
---|
| 24 | |
---|
| 25 | logger = logging.getLogger('Skins.import_uploads') |
---|
| 26 | mtool = context.portal_membership |
---|
| 27 | member = mtool.getAuthenticatedMember() |
---|
| 28 | |
---|
| 29 | lt = context.portal_layouts |
---|
| 30 | #pr = context.portal_registration |
---|
| 31 | |
---|
[3320] | 32 | ids = request.get('ids',[]) |
---|
[3296] | 33 | |
---|
| 34 | messages = [] |
---|
[3328] | 35 | disable_bypass = False |
---|
| 36 | |
---|
[3296] | 37 | for long_id in ids: |
---|
| 38 | short_id = long_id.replace('.csv','') |
---|
| 39 | doc = getattr(context, long_id).getContent() |
---|
[3324] | 40 | msg, invalid_keys = doc['checkKeys']() |
---|
| 41 | if msg: |
---|
| 42 | messages += msg, |
---|
| 43 | continue |
---|
| 44 | if not context.portal_catalog.getBypassQueue(): |
---|
[3296] | 45 | context.portal_catalog.setBypassQueue(1) |
---|
[3317] | 46 | context.waeup_tool.doCommit() |
---|
[3328] | 47 | disable_bypass = True |
---|
[3327] | 48 | |
---|
[3296] | 49 | msg = context.waeup_tool.importData(short_id, |
---|
| 50 | doc.import_layout, |
---|
| 51 | ) |
---|
| 52 | logger.info(msg) |
---|
| 53 | messages += msg, |
---|
| 54 | |
---|
[3328] | 55 | if disable_bypass: |
---|
[3296] | 56 | context.portal_catalog.setBypassQueue(0) |
---|
[3317] | 57 | context.waeup_tool.doCommit() |
---|
[3324] | 58 | |
---|
[3296] | 59 | args = {} |
---|
| 60 | args['portal_status_message'] = '\r\n'.join(messages) |
---|
| 61 | url = context.absolute_url() + '?' + urlencode(args) |
---|
[3320] | 62 | return request.RESPONSE.redirect(url) |
---|
[3296] | 63 | |
---|
[3320] | 64 | |
---|