def search_tag(self, auth, query, search_options=None):

        if search_options is None:
            search_options = {}

        #
        # sanitize search options and set default if option missing
        #

        # max_result
        if 'max_result' not in search_options:
            search_options['max_result'] = 50
        else:
            try:
                search_options['max_result'] = int(search_options['max_result'])
            except (ValueError, TypeError):
                raise NipapValueError('Invalid value for option' +
                    ''' 'max_result'. Only integer values allowed.''')

        # offset
        if 'offset' not in search_options:
            search_options['offset'] = 0
        else:
            try:
                search_options['offset'] = int(search_options['offset'])
            except (ValueError, TypeError):
                raise NipapValueError('Invalid value for option' +
                    ''' 'offset'. Only integer values allowed.''')

        self._logger.debug('search_tag search_options: %s' % str(search_options))

        opt = None
        sql = """ SELECT * FROM (SELECT DISTINCT unnest(tags) AS name FROM
        ip_net_plan) AS a """

        # add where clause if we have any search terms
        if query != {}:

            where, opt = self._expand_tag_query(query)
            sql += " WHERE " + where

        sql += " ORDER BY name LIMIT " + str(search_options['max_result'])
        self._execute(sql, opt)

        result = list()
        for row in self._curs_pg:
            result.append(dict(row))

        return { 'search_options': search_options, 'result': result }





# vim: et ts=4 :
Search Tags for entries matching 'query'
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap.search_tag