@logic.side_effect_free
def datastore_search(context, data_dict):
 schema = context.get('schema', dsschema.datastore_search_schema())
 (data_dict, errors) = _validate(data_dict, schema, context)
 if errors:
  raise p.toolkit.ValidationError(errors)
 res_id = data_dict['resource_id']
 data_dict['connection_url'] = config['ckan.datastore.write_url']
 resources_sql = sqlalchemy.text(u'SELECT alias_of FROM "_table_metadata"\n                                        WHERE name = :id')
 results = db._get_engine(data_dict).execute(resources_sql, id=res_id)
 if (not (results.rowcount > 0)):
  raise p.toolkit.ObjectNotFound(p.toolkit._('Resource "{0}" was not found.'.format(res_id)))
 if (not (data_dict['resource_id'] in WHITELISTED_RESOURCES)):
  resource_id = results.fetchone()[0]
  if resource_id:
   data_dict['resource_id'] = resource_id
  p.toolkit.check_access('datastore_search', context, data_dict)
 result = db.search(context, data_dict)
 result.pop('id', None)
 result.pop('connection_url')
 return result

@ logic . side_effect_free def datastore_search ( context , data_dict ) : schema = context . get ( 'schema' , dsschema . datastore_search_schema ( ) ) ( data_dict , errors ) = _validate ( data_dict , schema , context ) if errors : raise p . toolkit . ValidationError ( errors ) res_id = data_dict [ 'resource_id' ] data_dict [ 'connection_url' ] = config [ 'ckan.datastore.write_url' ] resources_sql = sqlalchemy . text ( u'SELECT alias_of FROM "_table_metadata"\n                                        WHERE name = :id' ) results = db . _get_engine ( data_dict ) . execute ( resources_sql , id = res_id ) if ( not ( results . rowcount > 0 ) ) : raise p . toolkit . ObjectNotFound ( p . toolkit . _ ( 'Resource "{0}" was not found.' . format ( res_id ) ) ) if ( not ( data_dict [ 'resource_id' ] in WHITELISTED_RESOURCES ) ) : resource_id = results . fetchone ( ) [ 0 ] if resource_id : data_dict [ 'resource_id' ] = resource_id p . toolkit . check_access ( 'datastore_search' , context , data_dict ) result = db . search ( context , data_dict ) result . pop ( 'id' , None ) result . pop ( 'connection_url' ) return result
search a datastore resource .