## Script (Python) "import_uploads" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=student=None ##title= ## # $Id:import_uploads.py 486 2006-09-06 10:09:39Z joachim $ """ do the import for uploads """ try: from Products.zdb import set_trace except: def set_trace(): pass request = context.REQUEST import DateTime, logging from urllib import urlencode current = DateTime.DateTime() pr = context.portal_registration logger = logging.getLogger('Skins.import_uploads') mtool = context.portal_membership member = mtool.getAuthenticatedMember() lt = context.portal_layouts #pr = context.portal_registration ids = request.get('ids',[]) messages = [] for long_id in ids: short_id = long_id.replace('.csv','') doc = getattr(context, long_id).getContent() msg, invalid_keys = doc['checkKeys']() if msg: messages += msg, continue if not context.portal_catalog.getBypassQueue(): context.portal_catalog.setBypassQueue(1) context.waeup_tool.doCommit() msg = context.waeup_tool.importData(short_id, doc.import_layout, ) logger.info(msg) messages += msg, if context.portal_catalog.getBypassQueue(): context.portal_catalog.setBypassQueue(0) context.waeup_tool.doCommit() args = {} args['portal_status_message'] = '\r\n'.join(messages) url = context.absolute_url() + '?' + urlencode(args) return request.RESPONSE.redirect(url)