зеркало из https://github.com/github/vitess-gh.git
Clean up py/vtdb class variables.
Remove class variables that shadow object variables. These are a potential source of hard-to-find bugs. Move initial values into object __init__ methods instead.
This commit is contained in:
Родитель
8381fb9d0b
Коммит
4bbd90babd
|
@ -6,16 +6,15 @@ from vtdb import dbexceptions
|
|||
|
||||
|
||||
class BaseCursor(object):
|
||||
arraysize = 1
|
||||
lastrowid = None
|
||||
rowcount = 0
|
||||
results = None
|
||||
connection = None
|
||||
description = None
|
||||
index = None
|
||||
|
||||
def __init__(self, connection):
|
||||
self.connection = connection
|
||||
self.arraysize = 1
|
||||
self.lastrowid = None
|
||||
self.rowcount = 0
|
||||
self.results = None
|
||||
self.description = None
|
||||
self.index = None
|
||||
|
||||
def close(self):
|
||||
self.connection = None
|
||||
|
@ -139,15 +138,14 @@ class BatchQueryItem(object):
|
|||
|
||||
|
||||
class StreamCursor(object):
|
||||
arraysize = 1
|
||||
conversions = None
|
||||
connection = None
|
||||
description = None
|
||||
index = None
|
||||
fetchmany_done = False
|
||||
|
||||
def __init__(self, connection):
|
||||
self.connection = connection
|
||||
self.arraysize = 1
|
||||
self.conversions = None
|
||||
self.description = None
|
||||
self.index = None
|
||||
self.fetchmany_done = False
|
||||
|
||||
def close(self):
|
||||
self.connection = None
|
||||
|
|
|
@ -2,23 +2,20 @@
|
|||
# Use of this source code is governed by a BSD-style license that can
|
||||
# be found in the LICENSE file.
|
||||
|
||||
from vtdb import cursor
|
||||
from vtdb import dbexceptions
|
||||
|
||||
|
||||
class Cursor(object):
|
||||
_conn = None
|
||||
tablet_type = None
|
||||
arraysize = 1
|
||||
lastrowid = None
|
||||
rowcount = 0
|
||||
results = None
|
||||
description = None
|
||||
index = None
|
||||
|
||||
def __init__(self, connection, tablet_type):
|
||||
self._conn = connection
|
||||
self.tablet_type = tablet_type
|
||||
self.arraysize = 1
|
||||
self.lastrowid = None
|
||||
self.rowcount = 0
|
||||
self.results = None
|
||||
self.description = None
|
||||
self.index = None
|
||||
|
||||
def close(self):
|
||||
self.results = None
|
||||
|
@ -111,12 +108,10 @@ class Cursor(object):
|
|||
|
||||
|
||||
class StreamCursor(Cursor):
|
||||
arraysize = 1
|
||||
conversions = None
|
||||
connection = None
|
||||
description = None
|
||||
index = None
|
||||
fetchmany_done = False
|
||||
|
||||
def __init__(self, connection, tablet_type):
|
||||
super(StreamCursor, self).__init__(connection, tablet_type)
|
||||
self.fetchmany_done = False
|
||||
|
||||
def execute(self, sql, bind_variables, **kargs):
|
||||
self.description = None
|
||||
|
|
|
@ -16,11 +16,6 @@ class Keyspace(object):
|
|||
|
||||
Provide functions to extract sharding information from the same.
|
||||
"""
|
||||
name = None
|
||||
partitions = None
|
||||
sharding_col_name = None
|
||||
sharding_col_type = None
|
||||
served_from = None
|
||||
|
||||
# load this object from a SrvKeyspace object generated by vt
|
||||
def __init__(self, name, data):
|
||||
|
|
|
@ -67,16 +67,16 @@ class TabletConnection(object):
|
|||
If something goes wrong, this object should be thrown away and a new
|
||||
one instantiated.
|
||||
"""
|
||||
transaction_id = 0
|
||||
session_id = 0
|
||||
_stream_fields = None
|
||||
_stream_conversions = None
|
||||
_stream_result = None
|
||||
_stream_result_index = None
|
||||
|
||||
def __init__(
|
||||
self, addr, tablet_type, keyspace, shard, timeout, user=None,
|
||||
password=None, keyfile=None, certfile=None, caller_id=None):
|
||||
self.transaction_id = 0
|
||||
self.session_id = 0
|
||||
self._stream_fields = None
|
||||
self._stream_conversions = None
|
||||
self._stream_result = None
|
||||
self._stream_result_index = None
|
||||
self.addr = addr
|
||||
self.tablet_type = tablet_type
|
||||
self.keyspace = keyspace
|
||||
|
|
|
@ -10,13 +10,6 @@ from zk import zkocc
|
|||
|
||||
|
||||
class VTConnParams(object):
|
||||
keyspace = None
|
||||
shard = None
|
||||
db_type = None
|
||||
addr = None
|
||||
timeout = 0
|
||||
user = None
|
||||
password = None
|
||||
|
||||
def __init__(self, keyspace_name, shard, db_type, addr, timeout,
|
||||
user, password):
|
||||
|
|
|
@ -88,14 +88,14 @@ def _create_req(sql, new_binds, tablet_type, not_in_transaction):
|
|||
|
||||
class VTGateConnection(object):
|
||||
"""This utilizes the V3 API of VTGate."""
|
||||
session = None
|
||||
_stream_fields = None
|
||||
_stream_conversions = None
|
||||
_stream_result = None
|
||||
_stream_result_index = None
|
||||
|
||||
def __init__(self, addr, timeout, user=None, password=None,
|
||||
keyfile=None, certfile=None):
|
||||
self._stream_fields = None
|
||||
self._stream_conversions = None
|
||||
self._stream_result = None
|
||||
self._stream_result_index = None
|
||||
self.session = None
|
||||
self.addr = addr
|
||||
self.timeout = timeout
|
||||
self.client = bsonrpc.BsonRpcClient(addr, timeout, user, password,
|
||||
|
|
Загрузка…
Ссылка в новой задаче