Browse Source

Changed the object_collection_name method in the utils of mongodb datasource plugin

Roland Haroutiounian 8 years ago
parent
commit
98ffe11d5f
2 changed files with 9 additions and 1 deletions
  1. 5
    0
      plugins/mongodb_datasource/datasource.py
  2. 4
    1
      plugins/mongodb_datasource/utils.py

+ 5
- 0
plugins/mongodb_datasource/datasource.py View File

@@ -97,6 +97,11 @@ class MongoDbDatasource(object):
97 97
 
98 98
         collection_name = object_collection_name(target)
99 99
         collection = self.database[collection_name]
100
+
101
+        if not target.abstract:
102
+            # Add the class name to the filters
103
+            filters.append(('classname', '=', target.__name__))
104
+
100 105
         query_filters = self.__process_filters(
101 106
             target, filters, rel_filters)
102 107
         query_result_ordering = None

+ 4
- 1
plugins/mongodb_datasource/utils.py View File

@@ -67,7 +67,10 @@ def connect(host, port, db_name, username, password):
67 67
 # @param class_object EmClass
68 68
 # @return str
69 69
 def object_collection_name(class_object):
70
-    return class_object.__name__
70
+    if class_object.abstract:
71
+        return class_object.__name__
72
+    else:
73
+        return object_collection_name(class_object.__base__)
71 74
 
72 75
 
73 76
 ## @brief Determine a collection field name given a lodel2 fieldname

Loading…
Cancel
Save