File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -28,15 +28,18 @@ def check_django_compatability():
28
28
29
29
def parse (uri ):
30
30
uri = parse_uri (uri )
31
- name = None
32
31
port = None
33
32
34
33
if uri ["fqdn" ] is None :
35
34
# If fqdn is None then this is not a SRV URI, so we need to extract the
36
35
# port from the first node in the nodelist.
37
36
if "nodelist" in uri and isinstance (uri ["nodelist" ], list ) and len (uri ["nodelist" ]) > 0 :
38
37
first_node = uri ["nodelist" ][0 ]
39
- if isinstance (first_node , tuple ) and len (first_node ) > 1 and isinstance (first_node [1 ], int ):
38
+ if (
39
+ isinstance (first_node , tuple )
40
+ and len (first_node ) > 1
41
+ and isinstance (first_node [1 ], int )
42
+ ):
40
43
port = first_node [1 ]
41
44
else :
42
45
# The fqdn is not none so we need to add the mongodb+srv:// prefix to the host.
@@ -46,11 +49,14 @@ def parse(uri):
46
49
"ENGINE" : "django_mongodb" ,
47
50
"NAME" : uri ["database" ],
48
51
"HOST" : host ,
49
- "PORT" : port ,
50
- "USERNAME" : uri .get ("username" ),
52
+ "USER" : uri .get ("username" ),
51
53
"PASSWORD" : uri .get ("password" ),
52
54
}
53
- return (url )
55
+
56
+ if port :
57
+ url ["PORT" ] = port
58
+
59
+ return url
54
60
55
61
56
62
def set_wrapped_methods (cls ):
You can’t perform that action at this time.
0 commit comments