Skip to content
Browse files

Added support for greenlets

  • Loading branch information...
1 parent 2f9c078 commit 5700a53e3ed9c20f23519732131101eb2b1dbdee Loïc Faure-Lacroix committed
Showing with 7 additions and 1 deletion.
  1. +7 −1 pyramid_mongo/__init__.py
View
8 pyramid_mongo/__init__.py
@@ -7,6 +7,7 @@
USERNAME = 'mongo.username'
PASSWORD = 'mongo.password'
DBNAME = 'mongo.db'
+GREENLETS = 'mongo.use_greenlets'
def get_connection(config, conn_cls=None):
"""get_connection creates a connection to one or more mongodb server.
@@ -23,6 +24,7 @@ def get_connection(config, conn_cls=None):
registry = config.registry
uri = registry.settings.get(URI)
+ greenlets = registry.settings.get(GREENLETS)
if uri is None:
raise ConfigurationError('There is no configured "mongo.uri"')
@@ -31,7 +33,11 @@ def get_connection(config, conn_cls=None):
if not isinstance(uri, list):
uri = uri.splitlines()
- return conn_cls(uri)
+ kargs = {
+ 'use_greenlets': asbool(greenlets)
+ }
+
+ return conn_cls(uri, **kargs)
def get_db(request, name=None):
"""get_db opens a handle for a database using a connection.

0 comments on commit 5700a53

Please sign in to comment.
Something went wrong with that request. Please try again.