diff -u -r1.6.2.12 LuciValidation.py --- conga-0.12.2/luci/site/luci/Extensions/LuciValidation.py 21 May 2009 13:32:04 -0000 1.6.2.12 +++ conga-0.12.2/luci/site/luci/Extensions/LuciValidation.py 22 Dec 2009 04:21:55 -0000 @@ -288,6 +288,37 @@ luci_log.debug_verbose('vSA1: error: %r %s: %r' % (e, str(e), form_xml)) return (False, { 'errors': [ 'The resource data submitted for this service is not properly formed' ]}) + service_name = fvar['svc_name'] + if service_name is None: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('vSA5: no service name') + errors.append('No service name was given') + + try: + cur_service = model.retrieveServiceByName(service_name) + except Exception, e: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('vSA5c: no service named %s found: %r %s' \ + % (service_name, e, str(e))) + cur_service = None + + action = fvar['action'] + if action is None: + return (False, {'errors': [ 'No action was given for service %s' % service_name ] }) + + if action == 'edit': + if cur_service is None: + return (False, {'errors': [ 'The service %s could not be found for editing' % service_name ]}) + model.deleteService(service_name) + elif action == 'add': + if cur_service is not None: + return (False, {'errors': [ 'A service with the name %s already exists' % service_name ]}) + else: + if LUCI_DEBUG_MODE is True: + luci_log.debug_verbose('vSA4a: unknown action %s' \ + % request.form['action']) + return (False, {'errors': [ 'An unknown action was specified' ]}) + form_hash = {} form_hash['toplevel'] = { 'form': None, 'kids': [] } for i in forms: @@ -391,13 +422,6 @@ errors.append('Restart expire time must be a number greater than or equal to 0') restart_expire_time = None - - service_name = fvar['svc_name'] - if service_name is None: - if LUCI_DEBUG_MODE is True: - luci_log.debug_verbose('vSA5: no service name') - errors.append('No service name was given') - nfslock = '0' try: if not request.form.has_key('nfslock') or request.form['nfslock'] != '1': @@ -429,31 +453,6 @@ except Exception, e: exclusive = '0' - try: - cur_service = model.retrieveServiceByName(service_name) - except Exception, e: - if LUCI_DEBUG_MODE is True: - luci_log.debug_verbose('vSA5c: no service named %s found: %r %s' \ - % (service_name, e, str(e))) - cur_service = None - - action = fvar['action'] - if action is None: - return (False, {'errors': [ 'No action was given for service %s' % service_name ] }) - - if action == 'edit': - if cur_service is None: - return (False, {'errors': [ 'The service %s could not be found for editing' % service_name ]}) - model.deleteService(service_name) - elif action == 'add': - if cur_service is not None: - return (False, {'errors': [ 'A service with the name %s already exists' % service_name ]}) - else: - if LUCI_DEBUG_MODE is True: - luci_log.debug_verbose('vSA4a: unknown action %s' \ - % request.form['action']) - return (False, {'errors': [ 'An unknown action was specified' ]}) - def buildSvcTree(parent, child_id_list): for i in child_id_list: try: