FileFields now copyable (#198)

This commit is contained in:
Ross Lawley
2012-12-21 17:09:10 +00:00
parent 1cdf71b647
commit b9e0f52526
3 changed files with 38 additions and 16 deletions

View File

@@ -986,14 +986,22 @@ class GridFSProxy(object):
self_dict['_fs'] = None
return self_dict
def __copy__(self):
copied = GridFSProxy()
copied.__dict__.update(self.__getstate__())
return copied
def __deepcopy__(self, memo):
return self.__copy__()
def __repr__(self):
return '<%s: %s>' % (self.__class__.__name__, self.grid_id)
def __eq__(self, other):
if isinstance(other, GridFSProxy):
return ((self.grid_id == other.grid_id) and
(self.collection_name == other.collection_name) and
(self.db_alias == other.db_alias))
return ((self.grid_id == other.grid_id) and
(self.collection_name == other.collection_name) and
(self.db_alias == other.db_alias))
else:
return False