0001 #------------------------------------------------------------------------- 0002 # This file contains real Python object wrappers for DB and DBEnv 0003 # C "objects" that can be usefully subclassed. The previous SWIG 0004 # based interface allowed this thanks to SWIG's shadow classes. 0005 # -- Gregory P. Smith 0006 #------------------------------------------------------------------------- 0007 # 0008 # (C) Copyright 2001 Autonomous Zone Industries 0009 # 0010 # License: This is free software. You may use this software for any 0011 # purpose including modification/redistribution, so long as 0012 # this header remains intact and that you do not claim any 0013 # rights of ownership or authorship of this software. This 0014 # software has been tested, but no warranty is expressed or 0015 # implied. 0016 # 0017 0018 # 0019 # TODO it would be *really nice* to have an automatic shadow class populator 0020 # so that new methods don't need to be added here manually after being 0021 # added to _bsddb.c. 0022 # 0023 0024 import db 0025 0026 try: 0027 from UserDict import DictMixin 0028 except ImportError: 0029 # DictMixin is new in Python 2.3 0030 class DictMixin: pass 0031 0032 class DBEnv: 0033 def __init__(self, *args, **kwargs): 0034 self._cobj = apply(db.DBEnv, args, kwargs) 0035 0036 def close(self, *args, **kwargs): 0037 return apply(self._cobj.close, args, kwargs) 0038 def open(self, *args, **kwargs): 0039 return apply(self._cobj.open, args, kwargs) 0040 def remove(self, *args, **kwargs): 0041 return apply(self._cobj.remove, args, kwargs) 0042 def set_shm_key(self, *args, **kwargs): 0043 return apply(self._cobj.set_shm_key, args, kwargs) 0044 def set_cachesize(self, *args, **kwargs): 0045 return apply(self._cobj.set_cachesize, args, kwargs) 0046 def set_data_dir(self, *args, **kwargs): 0047 return apply(self._cobj.set_data_dir, args, kwargs) 0048 def set_flags(self, *args, **kwargs): 0049 return apply(self._cobj.set_flags, args, kwargs) 0050 def set_lg_bsize(self, *args, **kwargs): 0051 return apply(self._cobj.set_lg_bsize, args, kwargs) 0052 def set_lg_dir(self, *args, **kwargs): 0053 return apply(self._cobj.set_lg_dir, args, kwargs) 0054 def set_lg_max(self, *args, **kwargs): 0055 return apply(self._cobj.set_lg_max, args, kwargs) 0056 def set_lk_detect(self, *args, **kwargs): 0057 return apply(self._cobj.set_lk_detect, args, kwargs) 0058 def set_lk_max(self, *args, **kwargs): 0059 return apply(self._cobj.set_lk_max, args, kwargs) 0060 def set_lk_max_locks(self, *args, **kwargs): 0061 return apply(self._cobj.set_lk_max_locks, args, kwargs) 0062 def set_lk_max_lockers(self, *args, **kwargs): 0063 return apply(self._cobj.set_lk_max_lockers, args, kwargs) 0064 def set_lk_max_objects(self, *args, **kwargs): 0065 return apply(self._cobj.set_lk_max_objects, args, kwargs) 0066 def set_mp_mmapsize(self, *args, **kwargs): 0067 return apply(self._cobj.set_mp_mmapsize, args, kwargs) 0068 def set_timeout(self, *args, **kwargs): 0069 return apply(self._cobj.set_timeout, args, kwargs) 0070 def set_tmp_dir(self, *args, **kwargs): 0071 return apply(self._cobj.set_tmp_dir, args, kwargs) 0072 def txn_begin(self, *args, **kwargs): 0073 return apply(self._cobj.txn_begin, args, kwargs) 0074 def txn_checkpoint(self, *args, **kwargs): 0075 return apply(self._cobj.txn_checkpoint, args, kwargs) 0076 def txn_stat(self, *args, **kwargs): 0077 return apply(self._cobj.txn_stat, args, kwargs) 0078 def set_tx_max(self, *args, **kwargs): 0079 return apply(self._cobj.set_tx_max, args, kwargs) 0080 def lock_detect(self, *args, **kwargs): 0081 return apply(self._cobj.lock_detect, args, kwargs) 0082 def lock_get(self, *args, **kwargs): 0083 return apply(self._cobj.lock_get, args, kwargs) 0084 def lock_id(self, *args, **kwargs): 0085 return apply(self._cobj.lock_id, args, kwargs) 0086 def lock_put(self, *args, **kwargs): 0087 return apply(self._cobj.lock_put, args, kwargs) 0088 def lock_stat(self, *args, **kwargs): 0089 return apply(self._cobj.lock_stat, args, kwargs) 0090 def log_archive(self, *args, **kwargs): 0091 return apply(self._cobj.log_archive, args, kwargs) 0092 def set_get_returns_none(self, *args, **kwargs): 0093 return apply(self._cobj.set_get_returns_none, args, kwargs) 0094 0095 if db.version() >= (4,1): 0096 def dbremove(self, *args, **kwargs): 0097 return apply(self._cobj.dbremove, args, kwargs) 0098 def dbrename(self, *args, **kwargs): 0099 return apply(self._cobj.dbrename, args, kwargs) 0100 def set_encrypt(self, *args, **kwargs): 0101 return apply(self._cobj.set_encrypt, args, kwargs) 0102 0103 0104 class DB(DictMixin): 0105 def __init__(self, dbenv, *args, **kwargs): 0106 # give it the proper DBEnv C object that its expecting 0107 self._cobj = apply(db.DB, (dbenv._cobj,) + args, kwargs) 0108 0109 # TODO are there other dict methods that need to be overridden? 0110 def __len__(self): 0111 return len(self._cobj) 0112 def __getitem__(self, arg): 0113 return self._cobj[arg] 0114 def __setitem__(self, key, value): 0115 self._cobj[key] = value 0116 def __delitem__(self, arg): 0117 del self._cobj[arg] 0118 0119 def append(self, *args, **kwargs): 0120 return apply(self._cobj.append, args, kwargs) 0121 def associate(self, *args, **kwargs): 0122 return apply(self._cobj.associate, args, kwargs) 0123 def close(self, *args, **kwargs): 0124 return apply(self._cobj.close, args, kwargs) 0125 def consume(self, *args, **kwargs): 0126 return apply(self._cobj.consume, args, kwargs) 0127 def consume_wait(self, *args, **kwargs): 0128 return apply(self._cobj.consume_wait, args, kwargs) 0129 def cursor(self, *args, **kwargs): 0130 return apply(self._cobj.cursor, args, kwargs) 0131 def delete(self, *args, **kwargs): 0132 return apply(self._cobj.delete, args, kwargs) 0133 def fd(self, *args, **kwargs): 0134 return apply(self._cobj.fd, args, kwargs) 0135 def get(self, *args, **kwargs): 0136 return apply(self._cobj.get, args, kwargs) 0137 def pget(self, *args, **kwargs): 0138 return apply(self._cobj.pget, args, kwargs) 0139 def get_both(self, *args, **kwargs): 0140 return apply(self._cobj.get_both, args, kwargs) 0141 def get_byteswapped(self, *args, **kwargs): 0142 return apply(self._cobj.get_byteswapped, args, kwargs) 0143 def get_size(self, *args, **kwargs): 0144 return apply(self._cobj.get_size, args, kwargs) 0145 def get_type(self, *args, **kwargs): 0146 return apply(self._cobj.get_type, args, kwargs) 0147 def join(self, *args, **kwargs): 0148 return apply(self._cobj.join, args, kwargs) 0149 def key_range(self, *args, **kwargs): 0150 return apply(self._cobj.key_range, args, kwargs) 0151 def has_key(self, *args, **kwargs): 0152 return apply(self._cobj.has_key, args, kwargs) 0153 def items(self, *args, **kwargs): 0154 return apply(self._cobj.items, args, kwargs) 0155 def keys(self, *args, **kwargs): 0156 return apply(self._cobj.keys, args, kwargs) 0157 def open(self, *args, **kwargs): 0158 return apply(self._cobj.open, args, kwargs) 0159 def put(self, *args, **kwargs): 0160 return apply(self._cobj.put, args, kwargs) 0161 def remove(self, *args, **kwargs): 0162 return apply(self._cobj.remove, args, kwargs) 0163 def rename(self, *args, **kwargs): 0164 return apply(self._cobj.rename, args, kwargs) 0165 def set_bt_minkey(self, *args, **kwargs): 0166 return apply(self._cobj.set_bt_minkey, args, kwargs) 0167 def set_cachesize(self, *args, **kwargs): 0168 return apply(self._cobj.set_cachesize, args, kwargs) 0169 def set_flags(self, *args, **kwargs): 0170 return apply(self._cobj.set_flags, args, kwargs) 0171 def set_h_ffactor(self, *args, **kwargs): 0172 return apply(self._cobj.set_h_ffactor, args, kwargs) 0173 def set_h_nelem(self, *args, **kwargs): 0174 return apply(self._cobj.set_h_nelem, args, kwargs) 0175 def set_lorder(self, *args, **kwargs): 0176 return apply(self._cobj.set_lorder, args, kwargs) 0177 def set_pagesize(self, *args, **kwargs): 0178 return apply(self._cobj.set_pagesize, args, kwargs) 0179 def set_re_delim(self, *args, **kwargs): 0180 return apply(self._cobj.set_re_delim, args, kwargs) 0181 def set_re_len(self, *args, **kwargs): 0182 return apply(self._cobj.set_re_len, args, kwargs) 0183 def set_re_pad(self, *args, **kwargs): 0184 return apply(self._cobj.set_re_pad, args, kwargs) 0185 def set_re_source(self, *args, **kwargs): 0186 return apply(self._cobj.set_re_source, args, kwargs) 0187 def set_q_extentsize(self, *args, **kwargs): 0188 return apply(self._cobj.set_q_extentsize, args, kwargs) 0189 def stat(self, *args, **kwargs): 0190 return apply(self._cobj.stat, args, kwargs) 0191 def sync(self, *args, **kwargs): 0192 return apply(self._cobj.sync, args, kwargs) 0193 def type(self, *args, **kwargs): 0194 return apply(self._cobj.type, args, kwargs) 0195 def upgrade(self, *args, **kwargs): 0196 return apply(self._cobj.upgrade, args, kwargs) 0197 def values(self, *args, **kwargs): 0198 return apply(self._cobj.values, args, kwargs) 0199 def verify(self, *args, **kwargs): 0200 return apply(self._cobj.verify, args, kwargs) 0201 def set_get_returns_none(self, *args, **kwargs): 0202 return apply(self._cobj.set_get_returns_none, args, kwargs) 0203 0204 if db.version() >= (4,1): 0205 def set_encrypt(self, *args, **kwargs): 0206 return apply(self._cobj.set_encrypt, args, kwargs) 0207
Generated by PyXR 0.9.4