| 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 | """ |
|---|
| 7 | try: |
|---|
| 8 | from Products.zdb import set_trace |
|---|
| 9 | except: |
|---|
| 10 | def set_trace(): |
|---|
| 11 | pass |
|---|
| 12 | import DateTime, logging |
|---|
| 13 | from urllib import urlencode |
|---|
| 14 | current = DateTime.DateTime() |
|---|
| 15 | pr = context.portal_registration |
|---|
| 16 | |
|---|
| 17 | logger = logging.getLogger('Skins.import') |
|---|
| 18 | mtool = context.portal_membership |
|---|
| 19 | member = mtool.getAuthenticatedMember() |
|---|
| 20 | |
|---|
| 21 | validate = REQUEST.has_key("import") |
|---|
| 22 | enable = REQUEST.has_key("enable_bypass") |
|---|
| 23 | disable = REQUEST.has_key("disable_bypass") |
|---|
| 24 | #set_trace() |
|---|
| 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 | ) |
|---|
| 36 | if enable: |
|---|
| 37 | context.portal_catalog.setBypassQueue(1) |
|---|
| 38 | logger.info('%s enabled QueueCatalog Bypass' % (member)) |
|---|
| 39 | psm = "QueueCatalog Bypass enabled!" |
|---|
| 40 | #return REQUEST.RESPONSE.redirect("%s" % context.absolute_url()) |
|---|
| 41 | elif disable: |
|---|
| 42 | context.portal_catalog.setBypassQueue(0) |
|---|
| 43 | logger.info('%s disabled QueueCatalog Bypass' % (member)) |
|---|
| 44 | psm = "QueueCatalog Bypass disabled!" |
|---|
| 45 | elif psm == 'invalid': |
|---|
| 46 | return context.import_form(rendered = res, |
|---|
| 47 | psm = "Please correct your input!", |
|---|
| 48 | ds = ds, |
|---|
| 49 | ) |
|---|
| 50 | elif psm == '': |
|---|
| 51 | return context.import_form(rendered = res, |
|---|
| 52 | psm = None, |
|---|
| 53 | ds = ds, |
|---|
| 54 | ) |
|---|
| 55 | elif psm == 'valid': |
|---|
| 56 | psm = context.waeup_tool.importData(ds.get('filename'), |
|---|
| 57 | ds.get('name'), |
|---|
| 58 | ds.get('import_or_edit') |
|---|
| 59 | ) |
|---|
| 60 | return context.import_form(rendered = res, |
|---|
| 61 | psm = psm, |
|---|
| 62 | ds = ds, |
|---|
| 63 | ) |
|---|