source: WAeUP_SRP/base/skins/waeup_upload/import_uploads.py @ 3327

Last change on this file since 3327 was 3327, checked in by Henrik Bettermann, 17 years ago

resolve pickle traceback

  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
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"""
12do the import for uploads
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19request = context.REQUEST
20import DateTime, logging
21from urllib import urlencode
22current = DateTime.DateTime()
23pr = context.portal_registration
24
25logger = logging.getLogger('Skins.import_uploads')
26mtool = context.portal_membership
27member = mtool.getAuthenticatedMember()
28
29lt = context.portal_layouts
30#pr = context.portal_registration
31
32ids = request.get('ids',[])
33
34messages = []
35for long_id in ids:
36    short_id = long_id.replace('.csv','')
37    doc = getattr(context, long_id).getContent()
38    msg, invalid_keys = doc['checkKeys']()
39    if msg:
40        messages += msg,
41        continue
42    if not context.portal_catalog.getBypassQueue():
43        context.portal_catalog.setBypassQueue(1)
44        context.waeup_tool.doCommit()
45
46    msg = context.waeup_tool.importData(short_id,
47                                        doc.import_layout,
48                                       )
49    logger.info(msg)
50    messages += msg,
51
52if context.portal_catalog.getBypassQueue():
53    context.portal_catalog.setBypassQueue(0)
54    context.waeup_tool.doCommit()
55
56args = {}
57args['portal_status_message'] = '\r\n'.join(messages)
58url = context.absolute_url() + '?' + urlencode(args)
59return request.RESPONSE.redirect(url)
60
61
Note: See TracBrowser for help on using the repository browser.