@@ -64,6 +64,7 @@ def __init__(self, conn):
64
64
self .conn = conn
65
65
self ._sync = None
66
66
self ._body = ''
67
+ self .pack_default = getattr (conn , "pack_default" , None )
67
68
68
69
def __bytes__ (self ):
69
70
return self .header (len (self ._body )) + self ._body
@@ -88,6 +89,10 @@ def header(self, length):
88
89
89
90
return msgpack .dumps (length + len (header )) + header
90
91
92
+ def msgpack_dumps (self , obj ):
93
+ return msgpack .dumps (obj , default = self .pack_default )
94
+
95
+
91
96
92
97
class RequestInsert (Request ):
93
98
'''
@@ -102,7 +107,7 @@ def __init__(self, conn, space_no, values):
102
107
super (RequestInsert , self ).__init__ (conn )
103
108
assert isinstance (values , (tuple , list ))
104
109
105
- request_body = msgpack . dumps ({IPROTO_SPACE_ID : space_no ,
110
+ request_body = self . msgpack_dumps ({IPROTO_SPACE_ID : space_no ,
106
111
IPROTO_TUPLE : values })
107
112
108
113
self ._body = request_body
@@ -131,19 +136,19 @@ def sha1(values):
131
136
hash2 = sha1 ((hash1 ,))
132
137
scramble = sha1 ((salt , hash2 ))
133
138
scramble = strxor (hash1 , scramble )
134
- request_body = msgpack . dumps ({IPROTO_USER_NAME : user ,
139
+ request_body = self . msgpack_dumps ({IPROTO_USER_NAME : user ,
135
140
IPROTO_TUPLE : ("chap-sha1" , scramble )})
136
141
self ._body = request_body
137
142
138
143
def header (self , length ):
139
144
self ._sync = self .conn .generate_sync ()
140
145
# Set IPROTO_SCHEMA_ID: 0 to avoid SchemaReloadException
141
146
# It is ok to use 0 in auth every time.
142
- header = msgpack . dumps ({IPROTO_CODE : self .request_type ,
147
+ header = self . msgpack_dumps ({IPROTO_CODE : self .request_type ,
143
148
IPROTO_SYNC : self ._sync ,
144
149
IPROTO_SCHEMA_ID : 0 })
145
150
146
- return msgpack . dumps (length + len (header )) + header
151
+ return self . msgpack_dumps (length + len (header )) + header
147
152
148
153
149
154
class RequestReplace (Request ):
@@ -159,7 +164,7 @@ def __init__(self, conn, space_no, values):
159
164
super (RequestReplace , self ).__init__ (conn )
160
165
assert isinstance (values , (tuple , list ))
161
166
162
- request_body = msgpack . dumps ({IPROTO_SPACE_ID : space_no ,
167
+ request_body = self . msgpack_dumps ({IPROTO_SPACE_ID : space_no ,
163
168
IPROTO_TUPLE : values })
164
169
165
170
self ._body = request_body
@@ -177,7 +182,7 @@ def __init__(self, conn, space_no, index_no, key):
177
182
'''
178
183
super (RequestDelete , self ).__init__ (conn )
179
184
180
- request_body = msgpack . dumps ({IPROTO_SPACE_ID : space_no ,
185
+ request_body = self . msgpack_dumps ({IPROTO_SPACE_ID : space_no ,
181
186
IPROTO_INDEX_ID : index_no ,
182
187
IPROTO_KEY : key })
183
188
@@ -193,7 +198,7 @@ class RequestSelect(Request):
193
198
# pylint: disable=W0231
194
199
def __init__ (self , conn , space_no , index_no , key , offset , limit , iterator ):
195
200
super (RequestSelect , self ).__init__ (conn )
196
- request_body = msgpack . dumps ({IPROTO_SPACE_ID : space_no ,
201
+ request_body = self . msgpack_dumps ({IPROTO_SPACE_ID : space_no ,
197
202
IPROTO_INDEX_ID : index_no ,
198
203
IPROTO_OFFSET : offset ,
199
204
IPROTO_LIMIT : limit ,
@@ -214,7 +219,7 @@ class RequestUpdate(Request):
214
219
def __init__ (self , conn , space_no , index_no , key , op_list ):
215
220
super (RequestUpdate , self ).__init__ (conn )
216
221
217
- request_body = msgpack . dumps ({IPROTO_SPACE_ID : space_no ,
222
+ request_body = self . msgpack_dumps ({IPROTO_SPACE_ID : space_no ,
218
223
IPROTO_INDEX_ID : index_no ,
219
224
IPROTO_KEY : key ,
220
225
IPROTO_TUPLE : op_list })
@@ -235,7 +240,7 @@ def __init__(self, conn, name, args, call_16):
235
240
super (RequestCall , self ).__init__ (conn )
236
241
assert isinstance (args , (list , tuple ))
237
242
238
- request_body = msgpack . dumps ({IPROTO_FUNCTION_NAME : name ,
243
+ request_body = self . msgpack_dumps ({IPROTO_FUNCTION_NAME : name ,
239
244
IPROTO_TUPLE : args })
240
245
241
246
self ._body = request_body
@@ -252,7 +257,7 @@ def __init__(self, conn, name, args):
252
257
super (RequestEval , self ).__init__ (conn )
253
258
assert isinstance (args , (list , tuple ))
254
259
255
- request_body = msgpack . dumps ({IPROTO_EXPR : name ,
260
+ request_body = self . msgpack_dumps ({IPROTO_EXPR : name ,
256
261
IPROTO_TUPLE : args })
257
262
258
263
self ._body = request_body
@@ -280,7 +285,7 @@ class RequestUpsert(Request):
280
285
def __init__ (self , conn , space_no , index_no , tuple_value , op_list ):
281
286
super (RequestUpsert , self ).__init__ (conn )
282
287
283
- request_body = msgpack . dumps ({IPROTO_SPACE_ID : space_no ,
288
+ request_body = self . msgpack_dumps ({IPROTO_SPACE_ID : space_no ,
284
289
IPROTO_INDEX_ID : index_no ,
285
290
IPROTO_TUPLE : tuple_value ,
286
291
IPROTO_OPS : op_list })
@@ -297,7 +302,7 @@ class RequestJoin(Request):
297
302
# pylint: disable=W0231
298
303
def __init__ (self , conn , server_uuid ):
299
304
super (RequestJoin , self ).__init__ (conn )
300
- request_body = msgpack . dumps ({IPROTO_SERVER_UUID : server_uuid })
305
+ request_body = self . msgpack_dumps ({IPROTO_SERVER_UUID : server_uuid })
301
306
self ._body = request_body
302
307
303
308
@@ -312,7 +317,7 @@ def __init__(self, conn, cluster_uuid, server_uuid, vclock):
312
317
super (RequestSubscribe , self ).__init__ (conn )
313
318
assert isinstance (vclock , dict )
314
319
315
- request_body = msgpack . dumps ({
320
+ request_body = self . msgpack_dumps ({
316
321
IPROTO_CLUSTER_UUID : cluster_uuid ,
317
322
IPROTO_SERVER_UUID : server_uuid ,
318
323
IPROTO_VCLOCK : vclock
@@ -329,6 +334,6 @@ class RequestOK(Request):
329
334
# pylint: disable=W0231
330
335
def __init__ (self , conn , sync ):
331
336
super (RequestOK , self ).__init__ (conn )
332
- request_body = msgpack . dumps ({IPROTO_CODE : self .request_type ,
337
+ request_body = self . msgpack_dumps ({IPROTO_CODE : self .request_type ,
333
338
IPROTO_SYNC : sync })
334
339
self ._body = request_body
0 commit comments