Martin v. Löwis | 6aa4a1f | 2002-11-19 08:09:52 +0000 | [diff] [blame^] | 1 | #------------------------------------------------------------------------- |
| 2 | # This file contains real Python object wrappers for DB and DBEnv |
| 3 | # C "objects" that can be usefully subclassed. The previous SWIG |
| 4 | # based interface allowed this thanks to SWIG's shadow classes. |
| 5 | # -- Gregory P. Smith |
| 6 | #------------------------------------------------------------------------- |
| 7 | # |
| 8 | # (C) Copyright 2001 Autonomous Zone Industries |
| 9 | # |
| 10 | # License: This is free software. You may use this software for any |
| 11 | # purpose including modification/redistribution, so long as |
| 12 | # this header remains intact and that you do not claim any |
| 13 | # rights of ownership or authorship of this software. This |
| 14 | # software has been tested, but no warranty is expressed or |
| 15 | # implied. |
| 16 | # |
| 17 | |
| 18 | import db |
| 19 | |
| 20 | |
| 21 | class DBEnv: |
| 22 | def __init__(self, *args, **kwargs): |
| 23 | self._cobj = apply(db.DBEnv, args, kwargs) |
| 24 | |
| 25 | def close(self, *args, **kwargs): |
| 26 | return apply(self._cobj.close, args, kwargs) |
| 27 | def open(self, *args, **kwargs): |
| 28 | return apply(self._cobj.open, args, kwargs) |
| 29 | def remove(self, *args, **kwargs): |
| 30 | return apply(self._cobj.remove, args, kwargs) |
| 31 | def set_cachesize(self, *args, **kwargs): |
| 32 | return apply(self._cobj.set_cachesize, args, kwargs) |
| 33 | def set_data_dir(self, *args, **kwargs): |
| 34 | return apply(self._cobj.set_data_dir, args, kwargs) |
| 35 | def set_flags(self, *args, **kwargs): |
| 36 | return apply(self._cobj.set_flags, args, kwargs) |
| 37 | def set_lg_bsize(self, *args, **kwargs): |
| 38 | return apply(self._cobj.set_lg_bsize, args, kwargs) |
| 39 | def set_lg_dir(self, *args, **kwargs): |
| 40 | return apply(self._cobj.set_lg_dir, args, kwargs) |
| 41 | def set_lg_max(self, *args, **kwargs): |
| 42 | return apply(self._cobj.set_lg_max, args, kwargs) |
| 43 | def set_lk_detect(self, *args, **kwargs): |
| 44 | return apply(self._cobj.set_lk_detect, args, kwargs) |
| 45 | def set_lk_max(self, *args, **kwargs): |
| 46 | return apply(self._cobj.set_lk_max, args, kwargs) |
| 47 | def set_lk_max_locks(self, *args, **kwargs): |
| 48 | return apply(self._cobj.set_lk_max_locks, args, kwargs) |
| 49 | def set_lk_max_lockers(self, *args, **kwargs): |
| 50 | return apply(self._cobj.set_lk_max_lockers, args, kwargs) |
| 51 | def set_lk_max_objects(self, *args, **kwargs): |
| 52 | return apply(self._cobj.set_lk_max_objects, args, kwargs) |
| 53 | def set_mp_mmapsize(self, *args, **kwargs): |
| 54 | return apply(self._cobj.set_mp_mmapsize, args, kwargs) |
| 55 | def set_tmp_dir(self, *args, **kwargs): |
| 56 | return apply(self._cobj.set_tmp_dir, args, kwargs) |
| 57 | def txn_begin(self, *args, **kwargs): |
| 58 | return apply(self._cobj.txn_begin, args, kwargs) |
| 59 | def txn_checkpoint(self, *args, **kwargs): |
| 60 | return apply(self._cobj.txn_checkpoint, args, kwargs) |
| 61 | def txn_stat(self, *args, **kwargs): |
| 62 | return apply(self._cobj.txn_stat, args, kwargs) |
| 63 | def set_tx_max(self, *args, **kwargs): |
| 64 | return apply(self._cobj.set_tx_max, args, kwargs) |
| 65 | def lock_detect(self, *args, **kwargs): |
| 66 | return apply(self._cobj.lock_detect, args, kwargs) |
| 67 | def lock_get(self, *args, **kwargs): |
| 68 | return apply(self._cobj.lock_get, args, kwargs) |
| 69 | def lock_id(self, *args, **kwargs): |
| 70 | return apply(self._cobj.lock_id, args, kwargs) |
| 71 | def lock_put(self, *args, **kwargs): |
| 72 | return apply(self._cobj.lock_put, args, kwargs) |
| 73 | def lock_stat(self, *args, **kwargs): |
| 74 | return apply(self._cobj.lock_stat, args, kwargs) |
| 75 | def log_archive(self, *args, **kwargs): |
| 76 | return apply(self._cobj.log_archive, args, kwargs) |
| 77 | def set_get_returns_none(self, *args, **kwargs): |
| 78 | return apply(self._cobj.set_get_returns_none, args, kwargs) |
| 79 | |
| 80 | |
| 81 | class DB: |
| 82 | def __init__(self, dbenv, *args, **kwargs): |
| 83 | # give it the proper DBEnv C object that its expecting |
| 84 | self._cobj = apply(db.DB, (dbenv._cobj,) + args, kwargs) |
| 85 | |
| 86 | # TODO are there other dict methods that need to be overridden? |
| 87 | def __len__(self): |
| 88 | return len(self._cobj) |
| 89 | def __getitem__(self, arg): |
| 90 | return self._cobj[arg] |
| 91 | def __setitem__(self, key, value): |
| 92 | self._cobj[key] = value |
| 93 | def __delitem__(self, arg): |
| 94 | del self._cobj[arg] |
| 95 | |
| 96 | def append(self, *args, **kwargs): |
| 97 | return apply(self._cobj.append, args, kwargs) |
| 98 | def associate(self, *args, **kwargs): |
| 99 | return apply(self._cobj.associate, args, kwargs) |
| 100 | def close(self, *args, **kwargs): |
| 101 | return apply(self._cobj.close, args, kwargs) |
| 102 | def consume(self, *args, **kwargs): |
| 103 | return apply(self._cobj.consume, args, kwargs) |
| 104 | def consume_wait(self, *args, **kwargs): |
| 105 | return apply(self._cobj.consume_wait, args, kwargs) |
| 106 | def cursor(self, *args, **kwargs): |
| 107 | return apply(self._cobj.cursor, args, kwargs) |
| 108 | def delete(self, *args, **kwargs): |
| 109 | return apply(self._cobj.delete, args, kwargs) |
| 110 | def fd(self, *args, **kwargs): |
| 111 | return apply(self._cobj.fd, args, kwargs) |
| 112 | def get(self, *args, **kwargs): |
| 113 | return apply(self._cobj.get, args, kwargs) |
| 114 | def get_both(self, *args, **kwargs): |
| 115 | return apply(self._cobj.get_both, args, kwargs) |
| 116 | def get_byteswapped(self, *args, **kwargs): |
| 117 | return apply(self._cobj.get_byteswapped, args, kwargs) |
| 118 | def get_size(self, *args, **kwargs): |
| 119 | return apply(self._cobj.get_size, args, kwargs) |
| 120 | def get_type(self, *args, **kwargs): |
| 121 | return apply(self._cobj.get_type, args, kwargs) |
| 122 | def join(self, *args, **kwargs): |
| 123 | return apply(self._cobj.join, args, kwargs) |
| 124 | def key_range(self, *args, **kwargs): |
| 125 | return apply(self._cobj.key_range, args, kwargs) |
| 126 | def has_key(self, *args, **kwargs): |
| 127 | return apply(self._cobj.has_key, args, kwargs) |
| 128 | def items(self, *args, **kwargs): |
| 129 | return apply(self._cobj.items, args, kwargs) |
| 130 | def keys(self, *args, **kwargs): |
| 131 | return apply(self._cobj.keys, args, kwargs) |
| 132 | def open(self, *args, **kwargs): |
| 133 | return apply(self._cobj.open, args, kwargs) |
| 134 | def put(self, *args, **kwargs): |
| 135 | return apply(self._cobj.put, args, kwargs) |
| 136 | def remove(self, *args, **kwargs): |
| 137 | return apply(self._cobj.remove, args, kwargs) |
| 138 | def rename(self, *args, **kwargs): |
| 139 | return apply(self._cobj.rename, args, kwargs) |
| 140 | def set_bt_minkey(self, *args, **kwargs): |
| 141 | return apply(self._cobj.set_bt_minkey, args, kwargs) |
| 142 | def set_cachesize(self, *args, **kwargs): |
| 143 | return apply(self._cobj.set_cachesize, args, kwargs) |
| 144 | def set_flags(self, *args, **kwargs): |
| 145 | return apply(self._cobj.set_flags, args, kwargs) |
| 146 | def set_h_ffactor(self, *args, **kwargs): |
| 147 | return apply(self._cobj.set_h_ffactor, args, kwargs) |
| 148 | def set_h_nelem(self, *args, **kwargs): |
| 149 | return apply(self._cobj.set_h_nelem, args, kwargs) |
| 150 | def set_lorder(self, *args, **kwargs): |
| 151 | return apply(self._cobj.set_lorder, args, kwargs) |
| 152 | def set_pagesize(self, *args, **kwargs): |
| 153 | return apply(self._cobj.set_pagesize, args, kwargs) |
| 154 | def set_re_delim(self, *args, **kwargs): |
| 155 | return apply(self._cobj.set_re_delim, args, kwargs) |
| 156 | def set_re_len(self, *args, **kwargs): |
| 157 | return apply(self._cobj.set_re_len, args, kwargs) |
| 158 | def set_re_pad(self, *args, **kwargs): |
| 159 | return apply(self._cobj.set_re_pad, args, kwargs) |
| 160 | def set_re_source(self, *args, **kwargs): |
| 161 | return apply(self._cobj.set_re_source, args, kwargs) |
| 162 | def set_q_extentsize(self, *args, **kwargs): |
| 163 | return apply(self._cobj.set_q_extentsize, args, kwargs) |
| 164 | def stat(self, *args, **kwargs): |
| 165 | return apply(self._cobj.stat, args, kwargs) |
| 166 | def sync(self, *args, **kwargs): |
| 167 | return apply(self._cobj.sync, args, kwargs) |
| 168 | def type(self, *args, **kwargs): |
| 169 | return apply(self._cobj.type, args, kwargs) |
| 170 | def upgrade(self, *args, **kwargs): |
| 171 | return apply(self._cobj.upgrade, args, kwargs) |
| 172 | def values(self, *args, **kwargs): |
| 173 | return apply(self._cobj.values, args, kwargs) |
| 174 | def verify(self, *args, **kwargs): |
| 175 | return apply(self._cobj.verify, args, kwargs) |
| 176 | def set_get_returns_none(self, *args, **kwargs): |
| 177 | return apply(self._cobj.set_get_returns_none, args, kwargs) |
| 178 | |