@@ -122,7 +122,7 @@ def session(self, access_mode=None):
122
122
within a single thread.
123
123
124
124
:param access_mode:
125
- :return : new :class:`.Session` object
125
+ :returns : new :class:`.Session` object
126
126
"""
127
127
pass
128
128
@@ -181,31 +181,34 @@ def close(self):
181
181
def closed (self ):
182
182
""" Indicator for whether or not this session has been closed.
183
183
184
- :return : :const:`True` if closed, :const:`False` otherwise.
184
+ :returns : :const:`True` if closed, :const:`False` otherwise.
185
185
"""
186
186
187
187
def run (self , statement , parameters = None , ** kwparameters ):
188
188
""" Run a Cypher statement within an auto-commit transaction.
189
+ Note that the statement is only passed to the server lazily,
190
+ when the result is consumed. To force the statement to be sent to
191
+ the server, use the :meth:`.Session.sync` method.
189
192
190
193
For usage details, see :meth:`.Transaction.run`.
191
194
192
195
:param statement: Cypher statement
193
196
:param parameters: dictionary of parameters
194
197
:param kwparameters: additional keyword parameters
195
- :return : :class:`.StatementResult` object
198
+ :returns : :class:`.StatementResult` object
196
199
"""
197
200
198
201
def fetch (self ):
199
202
""" Fetch the next message if available.
200
203
201
- :return : The number of messages fetched (zero or one)
204
+ :returns : The number of messages fetched (zero or one)
202
205
"""
203
206
return 0
204
207
205
208
def sync (self ):
206
209
""" Carry out a full send and receive.
207
210
208
- :return : Total number of records received
211
+ :returns : Total number of records received
209
212
"""
210
213
return 0
211
214
@@ -214,7 +217,7 @@ def begin_transaction(self, bookmark=None):
214
217
215
218
:param bookmark: a bookmark to which the server should
216
219
synchronise before beginning the transaction
217
- :return : new :class:`.Transaction` instance.
220
+ :returns : new :class:`.Transaction` instance.
218
221
:raise: :class:`.TransactionError` if a transaction is already open
219
222
"""
220
223
if self .transaction :
@@ -229,7 +232,7 @@ def clear_transaction():
229
232
def commit_transaction (self ):
230
233
""" Commit the current transaction.
231
234
232
- :return : the bookmark returned from the server, if any
235
+ :returns : the bookmark returned from the server, if any
233
236
:raise: :class:`.TransactionError` if no transaction is currently open
234
237
"""
235
238
if not self .transaction :
@@ -279,6 +282,9 @@ def __exit__(self, exc_type, exc_value, traceback):
279
282
280
283
def run (self , statement , parameters = None , ** kwparameters ):
281
284
""" Run a Cypher statement within the context of this transaction.
285
+ Note that the statement is only passed to the server lazily,
286
+ when the result is consumed. To force the statement to be sent to
287
+ the server, use the :meth:`.Transaction.sync` method.
282
288
283
289
Cypher is typically expressed as a statement template plus a
284
290
set of named parameters. In Python, parameters may be expressed
@@ -299,7 +305,7 @@ def run(self, statement, parameters=None, **kwparameters):
299
305
:param statement: Cypher statement
300
306
:param parameters: dictionary of parameters
301
307
:param kwparameters: additional keyword parameters
302
- :return : :class:`.StatementResult` object
308
+ :returns : :class:`.StatementResult` object
303
309
"""
304
310
if self .closed ():
305
311
raise TransactionError ("Cannot use closed transaction" )
@@ -350,13 +356,15 @@ def close(self):
350
356
351
357
def closed (self ):
352
358
""" Indicator to show whether the transaction has been closed.
353
- :return : :const:`True` if closed, :const:`False` otherwise.
359
+ :returns : :const:`True` if closed, :const:`False` otherwise.
354
360
"""
355
361
return self ._closed
356
362
357
363
358
364
class StatementResult (object ):
359
- """ A handler for the result of Cypher statement execution.
365
+ """ A handler for the result of Cypher statement execution. Instances
366
+ of this class are typically constructed and returned by
367
+ :meth:`.Session.run` and :meth:`.Transaction.run`.
360
368
"""
361
369
362
370
#: The statement text that was executed to produce this result.
@@ -385,36 +393,44 @@ def __iter__(self):
385
393
return self .records ()
386
394
387
395
def online (self ):
388
- """ True if this result is still attached to an active Session.
396
+ """ Indicator for whether or not this result is still attached to
397
+ a :class:`.Session`.
398
+
399
+ :returns: :const:`True` if still attached, :const:`False` otherwise
389
400
"""
390
401
return self ._session and not self ._session .closed ()
391
402
392
403
def fetch (self ):
393
- """ Fetch another record, if available. Return the number fetched.
404
+ """ Fetch another record, if available.
405
+
406
+ :returns: number of records fetched (zero or one)
394
407
"""
395
408
if self .online ():
396
409
return self ._session .fetch ()
397
410
else :
398
411
return 0
399
412
400
413
def buffer (self ):
401
- """ Fetch the remainder of the result from the network and buffer
402
- it for future consumption.
414
+ """ Fetch the remainder of this result from the network and buffer
415
+ it. On return from this method, the result will no longer be
416
+ :meth:`.online`.
403
417
"""
404
418
while self .online ():
405
419
self .fetch ()
406
420
407
421
def keys (self ):
408
- """ Return the keys for the records.
422
+ """ The keys for the records in this result.
423
+
424
+ :returns: tuple of key names
409
425
"""
410
426
while self ._keys is None and self .online ():
411
427
self .fetch ()
412
428
return self ._keys
413
429
414
430
def records (self ):
415
- """ Yield records.
431
+ """ Generator for records obtained from this result .
416
432
417
- :return:
433
+ :yields: iterable of :class:`.Record` objects
418
434
"""
419
435
hydrate = self .value_system .hydrate
420
436
zipper = self .zipper
@@ -430,20 +446,33 @@ def records(self):
430
446
yield zipper (keys , hydrate (values ))
431
447
432
448
def summary (self ):
433
- """ Return the summary, buffering any remaining records.
449
+ """ Obtain the summary of this result, buffering any remaining records.
450
+
451
+ :returns: The :class:`.ResultSummary` for this result
434
452
"""
435
453
self .buffer ()
436
454
return self ._summary
437
455
438
456
def consume (self ):
439
457
""" Consume the remainder of this result and return the summary.
458
+
459
+ .. NOTE:: It is generally recommended to use :meth:`.summary`
460
+ instead of this method.
461
+
462
+ :returns: The :class:`.ResultSummary` for this result
440
463
"""
441
464
if self .online ():
442
465
list (self )
443
466
return self .summary ()
444
467
445
468
def single (self ):
446
- """ Return the next record, failing if none or more than one remain.
469
+ """ Obtain the next and only remaining record from this result.
470
+
471
+ A warning is generated if more than one record is available but
472
+ the first of these is still returned.
473
+
474
+ :returns: the next :class:`.Record` or :const:`None` if none remain
475
+ :warns: if more than one record is available
447
476
"""
448
477
records = list (self )
449
478
size = len (records )
@@ -454,8 +483,10 @@ def single(self):
454
483
return records [0 ]
455
484
456
485
def peek (self ):
457
- """ Return the next record without advancing the cursor. Returns
458
- :const:`None` if no records remain.
486
+ """ Obtain the next record from this result without consuming it.
487
+ This leaves the record in the buffer for further processing.
488
+
489
+ :returns: the next :class:`.Record` or :const:`None` if none remain
459
490
"""
460
491
hydrate = self .value_system .hydrate
461
492
zipper = self .zipper
0 commit comments