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 22
33# Check Django compatibility before other imports which may fail if the
44# wrong version of Django is installed.
5- from .utils import check_django_compatability
5+ from .utils import check_django_compatability , parse
66
77check_django_compatability ()
88
Original file line number Diff line number Diff line change @@ -28,9 +28,20 @@ def check_django_compatability():
2828
2929def parse (uri ):
3030 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+
3141 return {
3242 "ENGINE" : "django_mongodb" ,
3343 "HOST" : uri ["fqdn" ] or None ,
44+ "PORT" : port ,
3445 "USERNAME" : uri .get ("username" ),
3546 "PASSWORD" : uri .get ("password" ),
3647 }
You can’t perform that action at this time.
0 commit comments