Example #1
0
 def test_get_tokenmaps(self):
     tokenmaps = db.get_tokenmaps(self.data_class)
     assert tokenmaps == {'encode': {}, 'decode': {}}
     result = self.data_class.put('tokenmaps', {
         '_id': 'test_collection',
         'abcdefg': '0',
         'ab|cd': '1',
         'abcd': '2'
     },
                                  consistency='STRONG')
     tokenmaps = db.get_tokenmaps(self.data_class)
     assert tokenmaps == {
         'encode': {
             'test_collection': {
                 'abcdefg': '0',
                 'ab|cd': '1',
                 'abcd': '2'
             }
         },
         'decode': {
             'test_collection': {
                 '0': 'abcdefg',
                 '1': 'ab|cd',
                 '2': 'abcd'
             }
         }
     }
Example #2
0
 def test_get_tokenmaps(self):
     tokenmaps = db.get_tokenmaps(self.data_class)
     assert tokenmaps == {"encode": {}, "decode": {}}
     result = self.data_class.put(
         "tokenmaps", {"_id": "test_collection", "abcdefg": "0", "ab|cd": "1", "abcd": "2"}, consistency="STRONG"
     )
     tokenmaps = db.get_tokenmaps(self.data_class)
     assert tokenmaps == {
         "encode": {"test_collection": {"abcdefg": "0", "ab|cd": "1", "abcd": "2"}},
         "decode": {"test_collection": {"0": "abcdefg", "1": "ab|cd", "2": "abcd"}},
     }
Example #3
0
 def init_app(self, app):
     app.extensions['data_wrapper'] = app.extensions.get('data_wrapper', {})
     app.extensions['data_wrapper']['ns'] = app.extensions[
         'data_wrapper'].get('ns', app.config['ENV'])
     self._ns = app.extensions['data_wrapper']['ns']
     app.extensions['data_wrapper']['tokenmaps'] = db.get_tokenmaps(self)
     self._tokenmaps = app.extensions['data_wrapper']['tokenmaps']
Example #4
0
 def __init__(self, app=None, config=None):
     if app:
         self.init_app(app)
     elif config:
         self._ns = config['ENV']
         self._tokenmaps = db.get_tokenmaps(self)
     else:
         raise Exception("app or config please!")
Example #5
0
 def __init__(self, app = None, config = None):
     if app:
         self.init_app(app)
     elif config:
         self._ns = config['ENV']
         self._tokenmaps = db.get_tokenmaps(self)
     else:
         raise Exception("app or config please!")
Example #6
0
 def __init__(self, app=None, config=None):
     if app:
         self.init_app(app)
     elif config:
         self._dbname = config['DB_NAME']
         self._db = os.path.join(os.path.dirname(os.path.abspath(__file__)), config['DB_NAME'])
         self._ns = config['ENV']
         self._tokenmaps = db.get_tokenmaps(self)
     else:
         raise Exception("app or config please!")
Example #7
0
    def init_app(self, app):
        app.extensions['data_wrapper'] = app.extensions.get('data_wrapper', {})
        app.extensions['data_wrapper']['db'] = os.path.join(os.path.dirname(os.path.abspath(__file__)), app.config['DB_NAME'])
        app.extensions['data_wrapper']['ns'] = app.extensions['data_wrapper'].get('ns', app.config['ENV'])

        self._dbname = app.config['DB_NAME']
        self._db = app.extensions['data_wrapper']['db']
        self._ns = app.extensions['data_wrapper']['ns']

        app.extensions['data_wrapper']['tokenmaps'] = db.get_tokenmaps(self)
        self._tokenmaps = app.extensions['data_wrapper']['tokenmaps']
Example #8
0
 def __init__(self, app = None, config = None):
     if app:
         self.init_app(app)
     elif config:
         self._connstr = config['DB_CONNECTION_STRING']
         self._conn = MongoClient(self._connstr)
         self._dbname = config['DB_NAME']
         self._db = self._conn[self._dbname]
         self._ns = config['ENV']
         self._tokenmaps = db.get_tokenmaps(self)
     else:
         raise Exception("app or config please!")
Example #9
0
    def init_app(self, app):
        app.extensions['data_wrapper'] = app.extensions.get('data_wrapper', {})
        app.extensions['data_wrapper']['db'] = app.extensions['data_wrapper'].get('db', None)
        if not app.extensions['data_wrapper']['db']:
            self._connstr = app.config['DB_CONNECTION_STRING']
            self._conn = MongoClient(self._connstr)
            self._dbname = app.config['DB_NAME']
            app.extensions['data_wrapper']['db'] = self._conn[self._dbname]
        app.extensions['data_wrapper']['ns'] = app.extensions['data_wrapper'].get('ns', app.config['ENV'])

        self._db = app.extensions['data_wrapper']['db']
        self._ns = app.extensions['data_wrapper']['ns']

        app.extensions['data_wrapper']['tokenmaps'] = db.get_tokenmaps(self)
        self._tokenmaps = app.extensions['data_wrapper']['tokenmaps']
Example #10
0
 def refresh_tokenmaps(self):
     self._tokenmaps = db.get_tokenmaps(self)
Example #11
0
 def init_app(self, app):
     app.extensions['data_wrapper'] = app.extensions.get('data_wrapper', {})
     app.extensions['data_wrapper']['ns'] = app.extensions['data_wrapper'].get('ns', app.config['ENV'])
     self._ns = app.extensions['data_wrapper']['ns']
     app.extensions['data_wrapper']['tokenmaps'] = db.get_tokenmaps(self)
     self._tokenmaps = app.extensions['data_wrapper']['tokenmaps']