[1756] | 1 | ##parameters=REQUEST |
---|
| 2 | # $Id: import.py 2315 2007-10-05 06:19:47Z henrik $ |
---|
| 3 | """ |
---|
| 4 | process the Application Form |
---|
| 5 | return html renderer + psm |
---|
| 6 | """ |
---|
[2259] | 7 | try: |
---|
| 8 | from Products.zdb import set_trace |
---|
| 9 | except: |
---|
| 10 | def set_trace(): |
---|
| 11 | pass |
---|
[2315] | 12 | import DateTime, logging |
---|
[1756] | 13 | from urllib import urlencode |
---|
| 14 | current = DateTime.DateTime() |
---|
| 15 | pr = context.portal_registration |
---|
| 16 | |
---|
[2314] | 17 | logger = logging.getLogger('Skins.import') |
---|
| 18 | mtool = context.portal_membership |
---|
| 19 | member = mtool.getAuthenticatedMember() |
---|
| 20 | |
---|
[1756] | 21 | validate = REQUEST.has_key("import") |
---|
[2259] | 22 | enable = REQUEST.has_key("enable_bypass") |
---|
| 23 | disable = REQUEST.has_key("disable_bypass") |
---|
| 24 | #set_trace() |
---|
[1756] | 25 | lt = context.portal_layouts |
---|
| 26 | #pr = context.portal_registration |
---|
| 27 | |
---|
| 28 | res,psm,ds = lt.renderLayout(layout_id= 'import', |
---|
| 29 | schema_id= 'import', |
---|
| 30 | context=context, |
---|
| 31 | mapping=validate and REQUEST, |
---|
| 32 | ob={}, |
---|
| 33 | layout_mode='create', |
---|
| 34 | commit=False, |
---|
| 35 | ) |
---|
[2259] | 36 | if enable: |
---|
| 37 | context.portal_catalog.setBypassQueue(1) |
---|
[2314] | 38 | logger.info('%s enabled QueueCatalog Bypass' % (member)) |
---|
[2262] | 39 | psm = "QueueCatalog Bypass enabled!" |
---|
| 40 | #return REQUEST.RESPONSE.redirect("%s" % context.absolute_url()) |
---|
[2259] | 41 | elif disable: |
---|
| 42 | context.portal_catalog.setBypassQueue(0) |
---|
[2314] | 43 | logger.info('%s disabled QueueCatalog Bypass' % (member)) |
---|
[2262] | 44 | psm = "QueueCatalog Bypass disabled!" |
---|
[2259] | 45 | elif psm == 'invalid': |
---|
[1756] | 46 | return context.import_form(rendered = res, |
---|
[1774] | 47 | psm = "Please correct your input!", |
---|
| 48 | ds = ds, |
---|
| 49 | ) |
---|
[1756] | 50 | elif psm == '': |
---|
| 51 | return context.import_form(rendered = res, |
---|
[1774] | 52 | psm = None, |
---|
| 53 | ds = ds, |
---|
| 54 | ) |
---|
[1756] | 55 | elif psm == 'valid': |
---|
[2259] | 56 | psm = context.waeup_tool.importData(ds.get('filename'), |
---|
[1774] | 57 | ds.get('name'), |
---|
| 58 | ds.get('import_or_edit') |
---|
| 59 | ) |
---|
[1756] | 60 | return context.import_form(rendered = res, |
---|
| 61 | psm = psm, |
---|
| 62 | ds = ds, |
---|
| 63 | ) |
---|