Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/olpc/datastore/model.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/olpc/datastore/model.py')
-rw-r--r--src/olpc/datastore/model.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/olpc/datastore/model.py b/src/olpc/datastore/model.py
index 46f2225..4c592be 100644
--- a/src/olpc/datastore/model.py
+++ b/src/olpc/datastore/model.py
@@ -167,6 +167,10 @@ class Model(object):
args = self.fields[fn]
addField(args[0], **args[2])
+
+# Properties we don't automatically include in properties dict
+EXCLUDED_PROPERTIES = ['fulltext', ]
+
class Content(object):
"""A light weight proxy around Xapian Documents from secore.
This provides additional methods which are used in the
@@ -199,6 +203,8 @@ class Content(object):
def properties(self):
d = {}
for k, v in self.data.iteritems():
+ if k in EXCLUDED_PROPERTIES: continue
+
if isinstance(v, list) and len(v) == 1:
v = v[0]
field = self._model.fields.get(k)
@@ -238,8 +244,14 @@ class Content(object):
return None, None
def get_file(self):
- if not hasattr(self, "_file") or self._file.closed is True:
- self.backingstore.get(self.id)
+ if not hasattr(self, "_file") or not self._file or \
+ self._file.closed is True:
+ target, ext = self.suggestName()
+ try:
+ targetfile = self.backingstore._targetFile(self.id, target, ext)
+ self._file = targetfile
+ except OSError:
+ self._file = None
return self._file
def set_file(self, fileobj):