Add gettext feature (/gettext/<aoid>)
This commit is contained in:
@@ -19,6 +19,7 @@ class FiasFactory:
|
||||
self.searcher = SphinxSearch(self.db)
|
||||
self.expand_templ = template('aore/templates/postgre/expand_query.sql', aoid="//aoid")
|
||||
self.normalize_templ = template('aore/templates/postgre/normalize_query.sql', aoid="//aoid")
|
||||
self.gettext_templ = template('aore/templates/postgre/gettext_query.sql', aoid="//aoid")
|
||||
|
||||
# Проверка, что строка является действительым UUID v4
|
||||
@staticmethod
|
||||
@@ -97,3 +98,20 @@ class FiasFactory:
|
||||
return dict(error=err.args[0])
|
||||
|
||||
return rows
|
||||
|
||||
# Возвращает простую текстовую строку по указанному AOID (при AOGUID будет
|
||||
# ошибка, так что нужно предварительно нормализовать), ищет и в
|
||||
def gettext(self, aoid):
|
||||
try:
|
||||
self.__check_param(aoid, "uuid")
|
||||
|
||||
sql_query = self.gettext_templ.replace("//aoid", aoid)
|
||||
rows = self.db.get_rows(sql_query, True)
|
||||
|
||||
assert len(rows), "Record with this AOID not found in DB"
|
||||
except Exception, err:
|
||||
if BasicConfig.logging:
|
||||
logging.error(traceback.format_exc(err))
|
||||
return dict(error=err.args[0])
|
||||
|
||||
return rows
|
||||
|
||||
Reference in New Issue
Block a user