projects
/
osm
/
RO.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lightweight exception capturing, logging
[osm/RO.git]
/
lcm
/
osm_common
/
dbmemory.py
diff --git
a/lcm/osm_common/dbmemory.py
b/lcm/osm_common/dbmemory.py
index
75d1f88
..
cdb0482
100644
(file)
--- a/
lcm/osm_common/dbmemory.py
+++ b/
lcm/osm_common/dbmemory.py
@@
-1,14
+1,22
@@
-from dbbase import DbException, dbbase
+import logging
+from dbbase import DbException, DbBase
from http import HTTPStatus
from uuid import uuid4
from copy import deepcopy
from http import HTTPStatus
from uuid import uuid4
from copy import deepcopy
+__author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
-class dbmemory(dbbase):
- def __init__(self):
+class DbMemory(DbBase):
+
+ def __init__(self, logger_name='db'):
+ self.logger = logging.getLogger(logger_name)
self.db = {}
self.db = {}
+ def db_connect(self, config):
+ if "logger_name" in config:
+ self.logger = logging.getLogger(config["logger_name"])
+
@staticmethod
def _format_filter(filter):
return filter # TODO
@staticmethod
def _format_filter(filter):
return filter # TODO
@@
-45,7
+53,7
@@
class dbmemory(dbbase):
HTTPStatus.CONFLICT.value)
l = row
if not l and fail_on_empty:
HTTPStatus.CONFLICT.value)
l = row
if not l and fail_on_empty:
- raise DbException("Not found entry with filter='{}'".format(filter), HTTPStatus.NOT_FOUND
.value
)
+ raise DbException("Not found entry with filter='{}'".format(filter), HTTPStatus.NOT_FOUND)
return deepcopy(l)
except Exception as e: # TODO refine
raise DbException(str(e))
return deepcopy(l)
except Exception as e: # TODO refine
raise DbException(str(e))
@@
-70,7
+78,7
@@
class dbmemory(dbbase):
break
else:
if fail_on_empty:
break
else:
if fail_on_empty:
- raise DbException("Not found entry with filter='{}'".format(filter), HTTPStatus.NOT_FOUND
.value
)
+ raise DbException("Not found entry with filter='{}'".format(filter), HTTPStatus.NOT_FOUND)
return None
del self.db[table][i]
return {"deleted": 1}
return None
del self.db[table][i]
return {"deleted": 1}
@@
-83,7
+91,7
@@
class dbmemory(dbbase):
break
else:
if fail_on_empty:
break
else:
if fail_on_empty:
- raise DbException("Not found entry with filter='{}'".format(filter), HTTPStatus.NOT_FOUND
.value
)
+ raise DbException("Not found entry with filter='{}'".format(filter), HTTPStatus.NOT_FOUND)
return None
self.db[table][i] = deepcopy(indata)
return {"upadted": 1}
return None
self.db[table][i] = deepcopy(indata)
return {"upadted": 1}