File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
# Check Django compatibility before other imports which may fail if the
4
4
# wrong version of Django is installed.
5
- from .utils import check_django_compatability
5
+ from .utils import check_django_compatability , parse
6
6
7
7
check_django_compatability ()
8
8
Original file line number Diff line number Diff line change @@ -28,9 +28,20 @@ def check_django_compatability():
28
28
29
29
def parse (uri ):
30
30
uri = parse_uri (uri )
31
+
32
+ # If fqdn is None then this is not a SRV URI, so we need to extract the port
33
+ # from the first node in the nodelist.
34
+ port = None
35
+ if uri ["fqdn" ] is None :
36
+ if "nodelist" in uri and isinstance (uri ["nodelist" ], list ) and len (uri ["nodelist" ]) > 0 :
37
+ first_node = uri ["nodelist" ][0 ]
38
+ if isinstance (first_node , tuple ) and len (first_node ) > 1 and isinstance (first_node [1 ], int ):
39
+ port = first_node [1 ]
40
+
31
41
return {
32
42
"ENGINE" : "django_mongodb" ,
33
43
"HOST" : uri ["fqdn" ] or None ,
44
+ "PORT" : port ,
34
45
"USERNAME" : uri .get ("username" ),
35
46
"PASSWORD" : uri .get ("password" ),
36
47
}
You can’t perform that action at this time.
0 commit comments