add _id property to GridFile instances

This commit is contained in:
Mike Dirolf 2010-03-17 10:06:50 -04:00
parent 705dae8598
commit 786f1de795
2 changed files with 10 additions and 0 deletions

View File

@ -164,6 +164,12 @@ class GridFile(object):
self.__collection.chunks.remove({"files_id": self.__id})
@property
def _id(self):
"""Get the value of ``"_id"`` for this :class:`GridFile`.
"""
return self.__id
@property
def closed(self):
"""Is this :class:`GridFile` closed?

View File

@ -426,6 +426,10 @@ class TestGridFile(unittest.TestCase):
self.assertEqual(in_data, out_data)
def test_id(self):
file = GridFile({"_id": "test"}, self.db, "w")
self.assertEqual("test", file._id)
if __name__ == "__main__":
unittest.main()