diff --git a/gridfs/grid_file.py b/gridfs/grid_file.py index bba687796..8e1a72628 100644 --- a/gridfs/grid_file.py +++ b/gridfs/grid_file.py @@ -164,17 +164,17 @@ class GridFile(object): self.__collection.chunks.remove({"files_id": self.__id}) + @property def closed(self): """Is this :class:`GridFile` closed? """ return self.__closed - closed = property(closed) + @property def mode(self): """Mode this :class:`GridFile` was opened with. """ return self.__mode - mode = property(mode) def __create_property(field_name, docstring, read_only=False): def getter(self): diff --git a/pymongo/binary.py b/pymongo/binary.py index fbe424758..dace7fd4b 100644 --- a/pymongo/binary.py +++ b/pymongo/binary.py @@ -44,11 +44,11 @@ class Binary(str): self.__subtype = subtype return self + @property def subtype(self): """Subtype of this binary data. """ return self.__subtype - subtype = property(subtype) def __eq__(self, other): if isinstance(other, Binary): diff --git a/pymongo/code.py b/pymongo/code.py index f2f64f2e4..e9359bff4 100644 --- a/pymongo/code.py +++ b/pymongo/code.py @@ -45,11 +45,11 @@ class Code(str): self.__scope = scope return self + @property def scope(self): """Scope dictionary for this instance. """ return self.__scope - scope = property(scope) def __repr__(self): return "Code(%s, %r)" % (str.__repr__(self), self.__scope) diff --git a/pymongo/collection.py b/pymongo/collection.py index 2a376efc8..20abb9491 100644 --- a/pymongo/collection.py +++ b/pymongo/collection.py @@ -118,6 +118,7 @@ class Collection(object): (other.__database, other.__name)) return NotImplemented + @property def full_name(self): """The full name of this :class:`Collection`. @@ -128,8 +129,8 @@ class Collection(object): ``full_name()`` method is deprecated. """ return self.__full_name_w - full_name = property(full_name) + @property def name(self): """The name of this :class:`Collection`. @@ -138,8 +139,8 @@ class Collection(object): ``name()`` method is deprecated. """ return self.__name_w - name = property(name) + @property def database(self): """The :class:`~pymongo.database.Database` that this :class:`Collection` is a part of. @@ -149,7 +150,6 @@ class Collection(object): ``database()`` method is deprecated. """ return self.__database_w - database = property(database) def save(self, to_save, manipulate=True, safe=False): """Save a document in this collection. diff --git a/pymongo/connection.py b/pymongo/connection.py index 053481ef4..53397e16e 100644 --- a/pymongo/connection.py +++ b/pymongo/connection.py @@ -295,6 +295,7 @@ class Connection(object): # TODO support auth for pooling if index_name in self.__index_cache[database_name][collection_name]: del self.__index_cache[database_name][collection_name][index_name] + @property def host(self): """Current connected host. @@ -303,8 +304,8 @@ class Connection(object): # TODO support auth for pooling method is deprecated. """ return helpers.callable_value(self.__host, "Connection.host") - host = property(host) + @property def port(self): """Current connected port. @@ -313,13 +314,12 @@ class Connection(object): # TODO support auth for pooling method is deprecated. """ return helpers.callable_value(self.__port, "Connection.port") - port = property(port) + @property def slave_okay(self): """Is it okay for this connection to connect directly to a slave? """ return self.__slave_okay - slave_okay = property(slave_okay) def __find_master(self): """Create a new socket and use it to figure out who the master is. diff --git a/pymongo/cursor.py b/pymongo/cursor.py index d39c234bc..672f12aad 100644 --- a/pymongo/cursor.py +++ b/pymongo/cursor.py @@ -65,6 +65,7 @@ class Cursor(object): self.__retrieved = 0 self.__killed = False + @property def collection(self): """The :class:`~pymongo.collection.Collection` that this :class:`Cursor` is iterating. @@ -72,7 +73,6 @@ class Cursor(object): .. versionadded:: 1.1 """ return self.__collection - collection = property(collection) def __del__(self): if self.__id and not self.__killed: diff --git a/pymongo/database.py b/pymongo/database.py index b8267d597..1503c94ce 100644 --- a/pymongo/database.py +++ b/pymongo/database.py @@ -99,6 +99,7 @@ class Database(object): if method_overwritten(manipulator, "transform_outgoing"): self.__outgoing_manipulators.insert(0, manipulator) + @property def connection(self): """The :class:`~pymongo.connection.Connection` instance for this :class:`Database`. @@ -108,8 +109,8 @@ class Database(object): ``connection()`` method is deprecated. """ return self.__connection_w - connection = property(connection) + @property def name(self): """The name of this :class:`Database`. @@ -118,7 +119,6 @@ class Database(object): ``name()`` method is deprecated. """ return self.__name_w - name = property(name) def __cmp__(self, other): if isinstance(other, Database): diff --git a/pymongo/dbref.py b/pymongo/dbref.py index 580bdd400..629e291af 100644 --- a/pymongo/dbref.py +++ b/pymongo/dbref.py @@ -45,18 +45,19 @@ class DBRef(object): self.__id = id self.__database = database + @property def collection(self): """Get the name of this DBRef's collection as unicode. """ return self.__collection - collection = property(collection) + @property def id(self): """Get this DBRef's _id. """ return self.__id - id = property(id) + @property def database(self): """Get the name of this DBRef's database. @@ -65,7 +66,6 @@ class DBRef(object): .. versionadded:: 1.1.1 """ return self.__database - database = property(database) def as_doc(self): """Get the SON document representation of this DBRef. diff --git a/pymongo/master_slave_connection.py b/pymongo/master_slave_connection.py index 3c8ba233d..3b96ea0d4 100644 --- a/pymongo/master_slave_connection.py +++ b/pymongo/master_slave_connection.py @@ -58,21 +58,21 @@ class MasterSlaveConnection(object): self.__master = master self.__slaves = slaves + @property def master(self): return self.__master - master = property(master) + @property def slaves(self): return self.__slaves - slaves = property(slaves) + @property def slave_okay(self): """Is it okay for this connection to connect directly to a slave? This is always True for MasterSlaveConnection instances. """ return True - slave_okay = property(slave_okay) def set_cursor_manager(self, manager_class): """Set the cursor manager for this connection. diff --git a/pymongo/objectid.py b/pymongo/objectid.py index ecef45468..ab817555a 100644 --- a/pymongo/objectid.py +++ b/pymongo/objectid.py @@ -121,12 +121,13 @@ class ObjectId(object): raise TypeError("id must be an instance of (str, ObjectId), " "not %s" % type(oid)) + @property def binary(self): """12-byte binary representation of this ObjectId. """ return self.__id - binary = property(binary) + @property def generation_time(self): """A :class:`datetime.datetime` instance representing the time of generation for this :class:`ObjectId`. @@ -138,7 +139,6 @@ class ObjectId(object): """ t = struct.unpack(">i", self.__id[0:4])[0] return datetime.datetime.utcfromtimestamp(t) - generation_time = property(generation_time) def __str__(self): return self.__id.encode("hex")