def get(self, dbname, key):
     dbm = self.get_dbm(dbname)
     try:
         key = key.lower().encode(self.charset, "replace")
         val = dbm.get(key)
         if isinstance(val, str):
             val = val.decode(self.charset, "replace")
         return val
     finally:
         dbm.close()
Exemple #2
0
 def update_record_caches(self):
     """This function will update the cached version of this type in all assosciated datarecords."""
     rows = self._dbm.load_all_rows_in_view(
         'datarecords_by_datatype_and_label', key=[self.id])
     records_to_update = [{
         'id': row.id,
         'label': row['key'][1]
     } for row in rows]
     for record in records_to_update:
         doc = dbm.get(record['id'], DataRecord)
Exemple #3
0
 def get(self, dbname, key):
     dbm = self.get_dbm(dbname)
     try:
         key = encode(key.lower())
         val = dbm.get(key)
         if isinstance(val, str):
             val = decode(val)
         return val
     finally:
         dbm.close()
Exemple #4
0
 def get(self, dbname, key):
     dbm = self.get_dbm(dbname)
     try:
         key = encode(key.lower())
         val = dbm.get(key)
         if isinstance(val, str):
             val = decode(val)
         return val
     finally:
         dbm.close()
Exemple #5
0
 def get(self, key):
     with self._dbm_file(False) as dbm:
         if hasattr(dbm, 'get'):
             value = dbm.get(key, NO_VALUE)
         else:
             # gdbm objects lack a .get method
             try:
                 value = dbm[key]
             except KeyError:
                 value = NO_VALUE
         if value is not NO_VALUE:
             value = compat.pickle.loads(value)
         return value
Exemple #6
0
 def get(self, key):
     with self._dbm_file(False) as dbm:
         if hasattr(dbm, 'get'):
             value = dbm.get(key, NO_VALUE)
         else:
             # gdbm objects lack a .get method
             try:
                 value = dbm[key]
             except KeyError:
                 value = NO_VALUE
         if value is not NO_VALUE:
             value = compat.pickle.loads(value)
         return value
Exemple #7
0
def get_datadict_type(dbm, id):
    assert isinstance(dbm, DatabaseManager)
    return dbm.get(id, DataDictType)
Exemple #8
0
def get_datadict_type(dbm, id):
    assert isinstance(dbm, DatabaseManager)
    return dbm.get(id, DataDictType)
Exemple #9
0
 def update_record_caches(self):
     """This function will update the cached version of this type in all assosciated datarecords."""
     rows = self._dbm.load_all_rows_in_view('datarecords_by_datatype_and_label', key=[self.id])
     records_to_update = [{'id': row.id, 'label': row['key'][1]} for row in rows]
     for record in records_to_update:
         doc = dbm.get(record['id'], DataRecord)