# set this is an eventtype reqObj.args['isEventType'] = [] reqObj.args['isEventType'].append('1') # call the Saved.process_set method try: logger.debug("Saving event type" + vals['name']) sessNS = reqObj.getSession().sessionNamespaces savedSearch = Saved(reqObj, reqObj.getSession(), SearchService.gSearchService) savedSearch.process_set() return True except: import traceback traceback.print_exc() return False if __name__ == '__main__': vals = { 'name': 'myname', 'query': 'this is my query', 'example': 'this is an example', 'tags': 'my,tag,are,cool', 'priority': '4', 'description': 'my desc' } result = _addToConf(vals, comm.getAuthInfo('admin', 'changeme')) print 'result: %s' % result
message = "<h1>Error: missing required field: %s</h1>" % field break else: vals[field] = defaultval session = requestObject.getSession() authString = session.sessionNamespaces['authXml'] sourcetype = vals.get('sourcetype', '') source = vals.get('source', '') if len(sourcetype) == 0 or sourcetype == "n/a": del vals['sourcetype'] vals["authstr"] = authString input_tail.add(vals, True) message = 'Source %s successfully added.' % source except Exception, e: message += 'Failed to add source: %s' % str(e) templ = Template.Template(bundle_paths.make_path('addtail_done.html')) templ.message = html.Raw('<p class="message">%s</p>' % message) return templ.get_string() if __name__ == '__main__': try: source = '/Users/davidcarasso/logs/exim.main.log' vals = {'source': source, 'sourcetype':'', 'index':'main'} vals["authstr"] = comm.getAuthInfo('admin','changeme') input_tail.add(vals, True) print 'Source %s successfully added.' % source except Exception, e: print 'Failed to add source: %s' % str(e)
break else: vals[field] = defaultval session = requestObject.getSession() authString = session.sessionNamespaces['authXml'] sourcetype = vals.get('sourcetype', '') source = vals.get('source', '') if len(sourcetype) == 0 or sourcetype == "n/a": del vals['sourcetype'] vals["authstr"] = authString input_tail.add(vals, True) message = 'Source %s successfully added.' % source except Exception as e: message += 'Failed to add source: %s' % str(e) templ = Template.Template(bundle_paths.make_path('addtail_done.html')) templ.message = html.Raw('<p class="message">%s</p>' % message) return templ.get_string() if __name__ == '__main__': try: source = '/Users/davidcarasso/logs/exim.main.log' vals = {'source': source, 'sourcetype': '', 'index': 'main'} vals["authstr"] = comm.getAuthInfo('admin', 'changeme') input_tail.add(vals, True) print('Source %s successfully added.' % source) except Exception as e: print('Failed to add source: %s' % str(e))
# check for a name if vals['name'] == '': return False # stuff the items from val into the reqObj args dictionary. for attr, val in vals.items(): if not reqObj.args.has_key(attr): reqObj.args[attr] = [] reqObj.args[attr].append(val) # set this is an eventtype reqObj.args['isEventType'] = [] reqObj.args['isEventType'].append('1') # call the Saved.process_set method try: logger.debug("Saving event type" + vals['name'] ) sessNS = reqObj.getSession().sessionNamespaces savedSearch = Saved(reqObj, reqObj.getSession(), SearchService.gSearchService) savedSearch.process_set() return True except: import traceback traceback.print_exc() return False if __name__ == '__main__': vals = {'name':'myname', 'query':'this is my query', 'example':'this is an example', 'tags':'my,tag,are,cool', 'priority':'4', 'description':'my desc'} result = _addToConf(vals, comm.getAuthInfo('admin','changeme')) print 'result: %s' % result