delayed_connect is now lazy_connect
This commit is contained in:
		| @@ -27,14 +27,14 @@ Host = namedtuple('Host', ['name', 'port']) | |||||||
|  |  | ||||||
| cluster = None | cluster = None | ||||||
| session = None | session = None | ||||||
| delayed_connect_args = None | lazy_connect_args = None | ||||||
| default_consistency_level = None | default_consistency_level = None | ||||||
|  |  | ||||||
| def setup( | def setup( | ||||||
|         hosts, |         hosts, | ||||||
|         default_keyspace, |         default_keyspace, | ||||||
|         consistency=ConsistencyLevel.ONE, |         consistency=ConsistencyLevel.ONE, | ||||||
|         delayed_connect=False, |         lazy_connect=False, | ||||||
|         **kwargs): |         **kwargs): | ||||||
|     """ |     """ | ||||||
|     Records the hosts and connects to one of them |     Records the hosts and connects to one of them | ||||||
| @@ -45,10 +45,10 @@ def setup( | |||||||
|     :type default_keyspace: str |     :type default_keyspace: str | ||||||
|     :param consistency: The global consistency level |     :param consistency: The global consistency level | ||||||
|     :type consistency: int |     :type consistency: int | ||||||
|     :param delayed_connect: True if should not connect until first use |     :param lazy_connect: True if should not connect until first use | ||||||
|     :type delayed_connect: bool |     :type lazy_connect: bool | ||||||
|     """ |     """ | ||||||
|     global cluster, session, default_consistency_level, delayed_connect_args |     global cluster, session, default_consistency_level, lazy_connect_args | ||||||
|  |  | ||||||
|     if 'username' in kwargs or 'password' in kwargs: |     if 'username' in kwargs or 'password' in kwargs: | ||||||
|         raise CQLEngineException("Username & Password are now handled by using the native driver's auth_provider") |         raise CQLEngineException("Username & Password are now handled by using the native driver's auth_provider") | ||||||
| @@ -58,8 +58,8 @@ def setup( | |||||||
|         models.DEFAULT_KEYSPACE = default_keyspace |         models.DEFAULT_KEYSPACE = default_keyspace | ||||||
|  |  | ||||||
|     default_consistency_level = consistency |     default_consistency_level = consistency | ||||||
|     if delayed_connect: |     if lazy_connect: | ||||||
|         delayed_connect_args = (hosts, default_keyspace, consistency, kwargs) |         lazy_connect_args = (hosts, default_keyspace, consistency, kwargs) | ||||||
|         return |         return | ||||||
|  |  | ||||||
|     cluster = Cluster(hosts, **kwargs) |     cluster = Cluster(hosts, **kwargs) | ||||||
| @@ -71,7 +71,7 @@ def execute(query, params=None, consistency_level=None): | |||||||
|     if not session: |     if not session: | ||||||
|         raise CQLEngineException("It is required to setup() cqlengine before executing queries") |         raise CQLEngineException("It is required to setup() cqlengine before executing queries") | ||||||
|  |  | ||||||
|     handle_delayed_connect() |     handle_lazy_connect() | ||||||
|  |  | ||||||
|     if consistency_level is None: |     if consistency_level is None: | ||||||
|         consistency_level = default_consistency_level |         consistency_level = default_consistency_level | ||||||
| @@ -96,16 +96,16 @@ def execute(query, params=None, consistency_level=None): | |||||||
|  |  | ||||||
|  |  | ||||||
| def get_session(): | def get_session(): | ||||||
|     handle_delayed_connect() |     handle_lazy_connect() | ||||||
|     return session |     return session | ||||||
|  |  | ||||||
| def get_cluster(): | def get_cluster(): | ||||||
|     handle_delayed_connect() |     handle_lazy_connect() | ||||||
|     return cluster |     return cluster | ||||||
|  |  | ||||||
| def handle_delayed_connect(): | def handle_lazy_connect(): | ||||||
|     global delayed_connect_args |     global lazy_connect_args | ||||||
|     if delayed_connect_args: |     if lazy_connect_args: | ||||||
|         hosts, default_keyspace, consistency, kwargs = delayed_connect_args |         hosts, default_keyspace, consistency, kwargs = lazy_connect_args | ||||||
|         delayed_connect_args = None |         lazy_connect_args = None | ||||||
|         setup(hosts, default_keyspace, consistency, **kwargs) |         setup(hosts, default_keyspace, consistency, **kwargs) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Cyrulnik
					Michael Cyrulnik