mediagoblin-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GMG-Devel] [PATCH 42/83] Store attributes from a model only it its avai


From: Alon Levy
Subject: [GMG-Devel] [PATCH 42/83] Store attributes from a model only it its available.
Date: Tue, 25 Feb 2014 21:58:25 +0200

From: Praveen Kumar <address@hidden>

---
 mediagoblin/plugins/search/base.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mediagoblin/plugins/search/base.py 
b/mediagoblin/plugins/search/base.py
index aca5967..5d56faa 100644
--- a/mediagoblin/plugins/search/base.py
+++ b/mediagoblin/plugins/search/base.py
@@ -174,13 +174,15 @@ class SearchIndex(object):
                 attr = None
                 if name.endswith('_stored'):
                     parent_name = name.replace('_stored', '')
-                    attr = getattr(obj, parent_name)
+                    attr = getattr(obj, parent_name, None)
                 else:
-                    attr = getattr(obj, name)
+                    attr = getattr(obj, name, None)
                 
                 if isinstance(attr, int):
                     attr = unicode(attr)
-                document[name] = attr
+
+                if attr:
+                    document[name] = attr
             except AttributeError:
                 _log.info("Attribute %s not found in %s"%(
                     name, obj.__class__.__name__))
-- 
1.8.5.3



reply via email to

[Prev in Thread] Current Thread [Next in Thread]