Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2012-10-20 06:43:53 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2012-10-20 06:43:53 (GMT)
commit988f3cb0562e6d363c2ea8943efcd5c9852dca55 (patch)
tree097de87c8ebdf27b48d95436533329ebc0f8b0af
parent1dc1d7708244f0384fd20c484158a9afb8e8399b (diff)
Polish design, move if_modified_since handling to app level
-rw-r--r--active_document/commands.py2
-rw-r--r--active_document/volume.py9
-rwxr-xr-xtests/units/volume.py42
3 files changed, 1 insertions, 52 deletions
diff --git a/active_document/commands.py b/active_document/commands.py
index 2a0d1b1..46dc228 100644
--- a/active_document/commands.py
+++ b/active_document/commands.py
@@ -91,8 +91,6 @@ class Request(dict):
access_level = env.ACCESS_REMOTE
accept_language = None
commands = None
- #: UNIX seconds of last modification
- if_modified_since = None
response = None
def __init__(self, props_=None, **kwargs):
diff --git a/active_document/volume.py b/active_document/volume.py
index 047ae63..65e4519 100644
--- a/active_document/volume.py
+++ b/active_document/volume.py
@@ -196,13 +196,6 @@ class VolumeCommands(CommandsProcessor):
prop = directory.metadata[prop]
doc = directory.get(guid)
doc.request = request
- meta = doc.meta(prop.name)
-
- if meta is not None:
- if request.if_modified_since:
- if meta['mtime'] <= request.if_modified_since:
- raise env.NotModified()
- response.last_modified = meta['mtime']
prop.assert_access(env.ACCESS_READ)
@@ -210,7 +203,7 @@ class VolumeCommands(CommandsProcessor):
value = doc.get(prop.name, request.accept_language or self._lang)
return prop.on_get(doc, value)
else:
- meta = prop.on_get(doc, meta)
+ meta = prop.on_get(doc, doc.meta(prop.name))
enforce(meta is not None and ('path' in meta or 'url' in meta),
env.NotFound, 'BLOB does not exist')
return meta
diff --git a/tests/units/volume.py b/tests/units/volume.py
index 454e8ca..777223d 100755
--- a/tests/units/volume.py
+++ b/tests/units/volume.py
@@ -237,48 +237,6 @@ class VolumeTest(tests.Test):
sorted(['prop']),
sorted(self.call('GET', document='testdocument', reply=['prop'])['result'][0].keys()))
- def test_Command_NotModifiedGet(self):
-
- class TestDocument(Document):
-
- @active_property(slot=1, default='')
- def prop(self, value):
- return value
-
- @active_property(BlobProperty)
- def blob(self, value):
- return value
-
- self.volume = SingleVolume(tests.tmpdir, [TestDocument])
-
- guid = self.call('POST', document='testdocument', content={})
- self.call('PUT', document='testdocument', guid=guid, prop='blob', content_stream=StringIO('value'))
- doc = self.volume['testdocument'].get(guid)
-
- try:
- self.call('GET', document='testdocument', guid=guid, prop='prop', if_modified_since=doc.meta('prop')['mtime'])
- assert False
- except ad.NotModified:
- pass
- try:
- self.call('GET', document='testdocument', guid=guid, prop='prop', if_modified_since=doc.meta('prop')['mtime'] + 1)
- assert False
- except ad.NotModified:
- pass
- self.call('GET', document='testdocument', guid=guid, prop='prop', if_modified_since=doc.meta('prop')['mtime'] - 1)
-
- try:
- self.call('GET', document='testdocument', guid=guid, prop='blob', if_modified_since=doc.meta('blob')['mtime'])
- assert False
- except ad.NotModified:
- pass
- try:
- self.call('GET', document='testdocument', guid=guid, prop='blob', if_modified_since=doc.meta('blob')['mtime'] + 1)
- assert False
- except ad.NotModified:
- pass
- self.call('GET', document='testdocument', guid=guid, prop='blob', if_modified_since=doc.meta('blob')['mtime'] - 1)
-
def test_LocalizedSet(self):
env.DEFAULT_LANG = 'en'