Exemplo n.º 1
0
 def _get_doc(self, database, table, id):
     tbl = sb.Table(table)
     with self.getCursor() as cur:
         cur.execute(sb.Select(sb.Field(table, '*'), tbl.id == id),
                     beacon="%s:%s:%s" % (database, table, id),
                     flush_hint=[table])
         res = cur.fetchone()
         return res['data'] if res is not None else None
Exemplo n.º 2
0
 def _get_doc_py_type(self, database, table, id):
     tbl = sb.Table(table)
     with self.getCursor() as cur:
         datafld = sb.Field(table, 'data')
         cur.execute(sb.Select(
             sb.JGET(datafld, interfaces.PY_TYPE_ATTR_NAME), tbl.id == id),
                     beacon="%s:%s:%s" % (database, table, id))
         res = cur.fetchone()
         return res[0] if res is not None else None
Exemplo n.º 3
0
 def __getitem__(self, key):
     with self._jar.getCursor(False) as cur:
         tbl = sb.Table(self.table)
         cur.execute(
             sb.Select(sb.Field(self.table, 'dbref'), tbl.name == key))
         if not cur.rowcount:
             raise KeyError(key)
         db, tbl, id = cur.fetchone()['dbref']
         dbref = serialize.DBRef(tbl, id, db)
         return self._jar.load(dbref)
Exemplo n.º 4
0
 def __delitem__(self, key):
     self._jar.remove(self[key])
     with self._jar.getCursor(False) as cur:
         tbl = sb.Table(self.table)
         cur.execute(sb.Delete(self.table, tbl.name == key))
Exemplo n.º 5
0
 def _pj_get_id_filter(self, id):
     tbl = sb.Table(self._pj_table)
     return (getattr(tbl, self._pj_id_column) == id)