@@ -136,6 +136,8 @@ class BatchQuery(object):
136136 Handles the batching of queries
137137
138138 http://www.datastax.com/docs/1.2/cql_cli/cql/BATCH
139+
140+ See :doc:`/cqlengine/batches` for more details.
139141 """
140142 warn_multiple_exec = True
141143
@@ -173,6 +175,11 @@ def __init__(self, batch_type=None, timestamp=None, consistency=None, execute_on
173175 self ._context_entered = False
174176
175177 def add_query (self , query ):
178+ """
179+ Adds a query to the batch.
180+
181+ :param query: The query
182+ """
176183 if not isinstance (query , BaseCQLStatement ):
177184 raise CQLEngineException ('only BaseCQLStatements can be added to a batch query' )
178185 self .queries .append (query )
@@ -202,6 +209,9 @@ def add_callback(self, fn, *args, **kwargs):
202209 self ._callbacks .append ((fn , args , kwargs ))
203210
204211 def execute (self ):
212+ """
213+ Executes the batch.
214+ """
205215 if self ._executed and self .warn_multiple_exec :
206216 msg = "Batch executed multiple times."
207217 if self ._context_entered :
@@ -260,8 +270,28 @@ def __exit__(self, exc_type, exc_val, exc_tb):
260270
261271
262272class ContextQuery (object ):
273+ """
274+ A Context manager to allow a Model to switch context easily. Presently, the context only
275+ specifies a keyspace for model IO.
276+
277+ For example:
278+
279+ .. code-block:: python
280+
281+ with ContextQuery(Automobile, keyspace='test2') as A:
282+ A.objects.create(manufacturer='honda', year=2008, model='civic')
283+ print len(A.objects.all()) # 1 result
284+
285+ with ContextQuery(Automobile, keyspace='test4') as A:
286+ print len(A.objects.all()) # 0 result
287+
288+ """
263289
264290 def __init__ (self , model , keyspace = None ):
291+ """
292+ :param model: A model
293+ :param keyspace: (optional) A keyspace name
294+ """
265295 from cassandra .cqlengine import models
266296
267297 if not issubclass (model , models .Model ):
0 commit comments