コード例 #1
0
ファイル: mongodb.py プロジェクト: ryandub/simpl
    def __init__(self, connection_string, disable_id_injector=True,
                 manipulators=None):
        """Initialize database wrapper.

        :param str connection_string: a full mongodb URL (supports creds too).
        :keyword bool disable_id_injector: see class docs for detailed info.
        :keyword list manipulators: a list of manipulator instances to add to
            each connection instance. Default is None, which sets two
            manipulators for handling JSON serialization and keys with "." in
            their name. To disable adding any manilutors, pass in a blank
            iterable (ex. [] or (,)).
        """
        self.connection_string = connection_string
        self.safe_connection_string = secrets.hide_url_password(
            self.connection_string)
        parsed = pymongo.uri_parser.parse_uri(self.connection_string)
        self.database_name = parsed['database']
        self.disable_id_injector = disable_id_injector
        self.manipulators = manipulators
        if self.manipulators is None:
            self.manipulators = [
                KeyTransform(".", "_dot_"),
                ObjectSerializer(),
            ]
        self._client = None
        self._connection = None
        if eventlet:
            eventlet.spawn_n(self.tune)
        else:
            self.tune()
コード例 #2
0
ファイル: mongodb.py プロジェクト: szilveszter/simpl
    def __init__(self,
                 connection_string,
                 disable_id_injector=True,
                 manipulators=None):
        """Initialize database wrapper.

        :param str connection_string: a full mongodb URL (supports creds too).
        :keyword bool disable_id_injector: see class docs for detailed info.
        :keyword list manipulators: a list of manipulator instances to add to
            each connection instance. Default is None, which sets two
            manipulators for handling JSON serialization and keys with "." in
            their name. To disable adding any manilutors, pass in a blank
            iterable (ex. [] or (,)).
        """
        self.connection_string = connection_string
        self.safe_connection_string = secrets.hide_url_password(
            self.connection_string)
        parsed = pymongo.uri_parser.parse_uri(self.connection_string)
        self.database_name = parsed['database']
        self.disable_id_injector = disable_id_injector
        self.manipulators = manipulators
        if self.manipulators is None:
            self.manipulators = [
                KeyTransform(".", "_dot_"),
                ObjectSerializer(),
            ]
        self._client = None
        self._connection = None
        if eventlet:
            self.client_lock = eventlet.semaphore.Semaphore()
            eventlet.spawn_n(self.tune)
        else:
            self.tune()
コード例 #3
0
 def test_git(self):
     hidden = secrets.hide_url_password('git+https://user:[email protected]')
     self.assertEqual(hidden, 'git+https://user:*****@github.com')
コード例 #4
0
 def test_mongo(self):
     hidden = secrets.hide_url_password('mongodb://*****:*****@localhost/db')
     self.assertEqual(hidden, 'mongodb://*****:*****@localhost/db')
コード例 #5
0
 def test_http(self):
     hidden = secrets.hide_url_password('http://*****:*****@localhost')
     self.assertEqual(hidden, 'http://*****:*****@localhost')
コード例 #6
0
ファイル: test_secrets.py プロジェクト: Gifflen/simpl
 def test_git(self):
     hidden = secrets.hide_url_password('git+https://user:[email protected]')
     self.assertEqual(hidden, 'git+https://user:*****@github.com')
コード例 #7
0
ファイル: test_secrets.py プロジェクト: Gifflen/simpl
 def test_mongo(self):
     hidden = secrets.hide_url_password('mongodb://*****:*****@localhost/db')
     self.assertEqual(hidden, 'mongodb://*****:*****@localhost/db')
コード例 #8
0
ファイル: test_secrets.py プロジェクト: Gifflen/simpl
 def test_http(self):
     hidden = secrets.hide_url_password('http://*****:*****@localhost')
     self.assertEqual(hidden, 'http://*****:*****@localhost')