mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 18:44:04 +01:00
Abstracted for some future overriding.
This commit is contained in:
parent
45f99cd1ee
commit
4cc1e4ba04
@ -221,10 +221,13 @@ class FlatfileMapping(MappingInterface):
|
|||||||
class CdbMapping(MappingInterface):
|
class CdbMapping(MappingInterface):
|
||||||
def __init__(self, filename, **kwargs):
|
def __init__(self, filename, **kwargs):
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.db = cdb.open(filename, 'c', **kwargs)
|
self._openCdb() # So it can be overridden later.
|
||||||
if 'nextId' not in self.db:
|
if 'nextId' not in self.db:
|
||||||
self.db['nextId'] = '1'
|
self.db['nextId'] = '1'
|
||||||
|
|
||||||
|
def _openCdb(self, *args, **kwargs):
|
||||||
|
self.db = cdb.open(filename, 'c', **kwargs)
|
||||||
|
|
||||||
def _getNextId(self):
|
def _getNextId(self):
|
||||||
i = int(self.db['nextId'])
|
i = int(self.db['nextId'])
|
||||||
self.db['nextId'] = str(i+1)
|
self.db['nextId'] = str(i+1)
|
||||||
|
Loading…
Reference in New Issue
Block a user