|
@@ -49,9 +49,11 @@ def get_connection_args(connnection_name='default'):
|
49
|
49
|
return connect(host, port, dbname, login, password)
|
50
|
50
|
'''
|
51
|
51
|
|
|
52
|
+
|
52
|
53
|
def connection_string(host, port, db_name, username, password):
|
53
|
54
|
return 'mongodb://%s:%s@%s:%s' % (username, password, host, port)
|
54
|
55
|
|
|
56
|
+
|
55
|
57
|
def connect(host, port, db_name, username, password):
|
56
|
58
|
connection = MongoClient(
|
57
|
59
|
connection_string(host, port, db_name, username, password))
|
|
@@ -59,7 +61,6 @@ def connect(host, port, db_name, username, password):
|
59
|
61
|
return database
|
60
|
62
|
|
61
|
63
|
|
62
|
|
-
|
63
|
64
|
## @brief Returns a collection name given a EmClass
|
64
|
65
|
# @param class_object EmClass
|
65
|
66
|
# @return str
|
|
@@ -72,26 +73,30 @@ def object_collection_name(class_object):
|
72
|
73
|
|
73
|
74
|
return collection_name
|
74
|
75
|
|
75
|
|
-##@brief Determine a collection field name given a lodel2 fieldname
|
76
|
|
-#@note For the moment this method only return the argument but EVERYWHERE
|
77
|
|
-#in the datasource we should use this method to gather proper fieldnames
|
78
|
|
-#@param fieldname str : A lodel2 fieldname
|
79
|
|
-#@return A string representing a well formated mongodb fieldname
|
80
|
|
-#@see mongo_filednames
|
|
76
|
+
|
|
77
|
+## @brief Determine a collection field name given a lodel2 fieldname
|
|
78
|
+# @note For the moment this method only return the argument but EVERYWHERE
|
|
79
|
+# in the datasource we should use this method to gather proper fieldnames
|
|
80
|
+# @param fieldname str : A lodel2 fieldname
|
|
81
|
+# @return A string representing a well formated mongodb fieldname
|
|
82
|
+# @see mongo_filednames
|
81
|
83
|
def mongo_fieldname(fieldname):
|
82
|
84
|
return fieldname
|
83
|
|
-##@brief Same as mongo_fieldname but for list of fields
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+## @brief Same as mongo_fieldname but for list of fields
|
84
|
88
|
#
|
85
|
|
-#A small utility function
|
86
|
|
-#@param fieldnames iterable : contains str only
|
87
|
|
-#@return a list of converted fildnames (str)
|
88
|
|
-#@see mongo_fieldname
|
|
89
|
+# A small utility function
|
|
90
|
+# @param fieldnames iterable : contains str only
|
|
91
|
+# @return a list of converted fildnames (str)
|
|
92
|
+# @see mongo_fieldname
|
89
|
93
|
def mongo_fieldnames(fieldnames):
|
90
|
94
|
return [mongo_fieldname(fname) for fname in fieldnames]
|
91
|
95
|
|
|
96
|
+
|
92
|
97
|
## @brief Returns a list of orting options
|
93
|
98
|
# @param query_filters_order list
|
94
|
99
|
# @return list
|
95
|
100
|
def parse_query_order(query_filters_order):
|
96
|
|
- return [ (field, LODEL_SORT_OPERATORS_MAP[direction])
|
97
|
|
- for field, direction in query_filters_order]
|
|
101
|
+ return [(field, LODEL_SORT_OPERATORS_MAP[direction])
|
|
102
|
+ for field, direction in query_filters_order]
|