summaryrefslogtreecommitdiff
path: root/src/saml2/mongo_store.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/saml2/mongo_store.py')
-rw-r--r--src/saml2/mongo_store.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/saml2/mongo_store.py b/src/saml2/mongo_store.py
index 065aeb43..a83d2f8b 100644
--- a/src/saml2/mongo_store.py
+++ b/src/saml2/mongo_store.py
@@ -266,25 +266,28 @@ def _mdb_get_database(uri, **kwargs):
:params database: name as string or (uri, name)
:returns: pymongo database object
"""
+ if not "tz_aware" in kwargs:
+ # default, but not forced
+ kwargs["tz_aware"] = True
+
connection_factory = MongoClient
_parsed_uri = {}
db_name = None
+ _conn = None
+
try:
_parsed_uri = pymongo.uri_parser.parse_uri(uri)
except pymongo.errors.InvalidURI:
# assume URI to be just the database name
db_name = uri
+ _conn = MongoClient()
pass
else:
if "replicaset" in _parsed_uri["options"]:
connection_factory = MongoReplicaSetClient
db_name = _parsed_uri.get("database", "pysaml2")
+ _conn = connection_factory(uri, **kwargs)
- if not "tz_aware" in kwargs:
- # default, but not forced
- kwargs["tz_aware"] = True
-
- _conn = connection_factory(uri, **kwargs)
_db = _conn[db_name]
if "username" in _parsed_uri: