txmongo package

Submodules

txmongo.collection module

class txmongo.collection.Collection(database, name)[source]

Bases: object

aggregate(pipeline, full_response=False)[source]
count(spec=None, fields=None)[source]
create_index(sort_fields, **kwargs)[source]
distinct(key, spec=None)[source]
drop(**kwargs)[source]
drop_index(index_identifier)[source]
drop_indexes()[source]
ensure_index(sort_fields, **kwargs)[source]
filemd5(spec)[source]
find(*args, **kwargs)[source]
find_and_modify(query=None, update=None, upsert=False, **kwargs)[source]
find_one(spec=None, fields=None, **kwargs)[source]
find_with_cursor(spec=None, skip=0, limit=0, fields=None, filter=None, **kwargs)[source]

find method that uses the cursor to only return a block of results at a time. Arguments are the same as with find() returns deferred that results in a tuple: (docs, deferred) where docs are the current page of results and deferred results in the next tuple. When the cursor is exhausted, it will return the tuple ([], None)

group(keys, initial, reduce, condition=None, finalize=None)[source]
index_information()[source]
insert(*args, **kwargs)[source]
map_reduce(map, reduce, full_response=False, **kwargs)[source]
options()[source]
remove(*args, **kwargs)[source]
rename(new_name)[source]
save(doc, safe=True, **kwargs)[source]
update(*args, **kwargs)[source]

txmongo.connection module

class txmongo.connection.ConnectionPool(uri='mongodb://127.0.0.1:27017', pool_size=1, ssl_context_factory=None)[source]

Bases: object

authenticate(*args, **kwargs)[source]
disconnect()[source]
get_default_database()[source]
getprotocol()[source]
getprotocols()[source]
uri
class txmongo.connection.MongoConnection(host='127.0.0.1', port=27017, pool_size=1)[source]

Bases: txmongo.connection.ConnectionPool

txmongo.connection.MongoConnectionPool

alias of MongoConnection

txmongo.connection.lazyMongoConnection

alias of MongoConnection

txmongo.connection.lazyMongoConnectionPool

alias of MongoConnection

txmongo.database module

class txmongo.database.Database(factory, database_name)[source]

Bases: object

authenticate(*args, **kwargs)[source]

Send an authentication command for this database. mostly stolen from pymongo

collection_names()[source]
connection
create_collection(name, options=None)[source]
drop_collection(name_or_collection)[source]
name

txmongo.dbref module

Tools for manipulating DBRefs (references to MongoDB documents).

class txmongo.dbref.DBRef(collection, id, database=None)[source]

Bases: object

A reference to a document stored in a Mongo database.

as_doc()[source]

Get the SON document representation of this DBRef.

Generally not needed by application developers

collection

Get the name of this DBRef’s collection as unicode.

database

Get the name of this DBRef’s database.

Returns None if this DBRef doesn’t specify a database.

New in version 1.1.1.

id

Get this DBRef’s _id.

txmongo.filter module

txmongo.filter.ASCENDING(keys)[source]

Ascending sort order

txmongo.filter.DESCENDING(keys)[source]

Descending sort order

txmongo.filter.GEO2D(keys)[source]

Two-dimensional geospatial index http://www.mongodb.org/display/DOCS/Geospatial+Indexing

txmongo.filter.GEO2DSPHERE(keys)[source]

Two-dimensional geospatial index http://www.mongodb.org/display/DOCS/Geospatial+Indexing

txmongo.filter.GEOHAYSTACK(keys)[source]

Bucket-based geospatial index http://www.mongodb.org/display/DOCS/Geospatial+Haystack+Indexing

class txmongo.filter.comment(comment)[source]

Bases: txmongo.filter._QueryFilter

class txmongo.filter.explain[source]

Bases: txmongo.filter._QueryFilter

Returns an explain plan for the query.

class txmongo.filter.hint(index_list)[source]

Bases: txmongo.filter._QueryFilter

Adds a hint, telling Mongo the proper index to use for the query.

class txmongo.filter.snapshot[source]

Bases: txmongo.filter._QueryFilter

class txmongo.filter.sort(key_list)[source]

Bases: txmongo.filter._QueryFilter

Sorts the results of a query.

txmongo.gridfs module

txmongo.protocol module

Low level connection to Mongo.

This module contains the wire protocol implementation for txmongo. The various constants from the protocol are available as constants.

This implementation requires pymongo so that as much of the implementation can be shared. This includes BSON encoding and decoding as well as Exception types, when applicable.

class txmongo.protocol.Delete[source]

Bases: txmongo.protocol.Delete

class txmongo.protocol.Getmore[source]

Bases: txmongo.protocol.Getmore

class txmongo.protocol.Insert[source]

Bases: txmongo.protocol.Insert

class txmongo.protocol.KillCursors[source]

Bases: txmongo.protocol.KillCursors

exception txmongo.protocol.MongoAuthenticationError[source]

Bases: exceptions.Exception

class txmongo.protocol.MongoClientProtocol[source]

Bases: twisted.internet.protocol.Protocol

get_request_id()[source]
send(request)[source]
send_DELETE(request)[source]
send_GETMORE(request)[source]
send_INSERT(request)[source]
send_KILL_CURSORS(request)[source]
send_MSG(request)[source]
send_QUERY(request)[source]
send_REPLY(request)[source]
send_UPDATE(request)[source]
class txmongo.protocol.MongoDecoder[source]
dataBuffer = None
static decode(message_data)[source]
feed(data)[source]
next()[source]
class txmongo.protocol.MongoProtocol[source]

Bases: txmongo.protocol.MongoServerProtocol, txmongo.protocol.MongoClientProtocol

authenticate(*args, **kwargs)[source]
authenticate_mongo_cr(*args, **kwargs)[source]
authenticate_scram_sha1(*args, **kwargs)[source]
connectionLost(reason=<twisted.python.failure.Failure <class 'twisted.internet.error.ConnectionDone'>>)[source]
connectionMade()[source]
connectionReady()[source]
fail(reason)[source]
get_last_error(*args, **kwargs)[source]
handle_REPLY(request)[source]
inflight()[source]
max_wire_version = None
min_wire_version = None
send_GETMORE(request)[source]
send_QUERY(request)[source]
set_wire_versions(min_wire_version, max_wire_version)[source]
class txmongo.protocol.MongoServerProtocol[source]

Bases: twisted.internet.protocol.Protocol

dataReceived(data)[source]
handle(request)[source]
handle_DELETE(request)[source]
handle_GETMORE(request)[source]
handle_INSERT(request)[source]
handle_KILL_CURSORS(request)[source]
handle_MSG(request)[source]
handle_QUERY(request)[source]
handle_REPLY(request)[source]
handle_UPDATE(request)[source]
class txmongo.protocol.Msg(len, request_id, response_to, opcode, message)

Bases: tuple

len

Alias for field number 0

message

Alias for field number 4

opcode

Alias for field number 3

request_id

Alias for field number 1

response_to

Alias for field number 2

class txmongo.protocol.Query[source]

Bases: txmongo.protocol.Query

class txmongo.protocol.Reply[source]

Bases: txmongo.protocol.Reply

class txmongo.protocol.Update[source]

Bases: txmongo.protocol.Update

Module contents