===========
MongoClient
===========

The client module provides a environment based pymongo client setup concept.

  >>> import string
  >>> from pprint import pprint
  >>> from pymongo.periodic_executor import _shutdown_executors
  >>> from m01.mongo import LOCAL
  >>> import m01.mongo.client
  >>> import m01.mongo.settings


MongoClient
-----------

  >>> pprint(LOCAL.__dict__)
  {}

  >>> client = m01.mongo.client.getMongoClient()
  >>> func, pars = str(client).split("(")
  >>> func
  'MongoClient'
  >>> sorted(pars.replace(")", "").split(","))
  [' connect=False', ' connecttimeoutms=20000', ' document_class=dict', ' heartbeatfrequencyms=10000', ' maxpoolsize=100', ' serverselectiontimeoutms=30000', ' sockettimeoutms=20000', ' tz_aware=True', ' waitqueuetimeoutms=20000', "host=['127.0.0.1:27017']"]


Settings
--------

The settings module provides the following variables:

  >>> UPPERCASE = tuple(string.ascii_uppercase)
  >>> print(('\n'.join([
  ...     v for v in dir(m01.mongo.settings)
  ...     if v.startswith(UPPERCASE)
  ...     ])))
  I18N_EXTRACT
  MONGODB_APP_NAME
  MONGODB_AUTH_MECHNISM
  MONGODB_CA_CERT
  MONGODB_CLIENT_CERT
  MONGODB_CLIENT_CERT_KEY_FILE
  MONGODB_CONNECT
  MONGODB_CONNECT_TIMEOUT
  MONGODB_HEARTBEAT_FREQUENCY
  MONGODB_MAX_IDLE_TIME_MS
  MONGODB_MAX_POOL_SIZE
  MONGODB_MIN_POOL_SIZE
  MONGODB_PASSWORD
  MONGODB_PEM_PASSPHRASE
  MONGODB_REPLICA_SET
  MONGODB_REVOCATION_LIST
  MONGODB_SERVER_SELECTION_TIMEOUT
  MONGODB_SOCKET_TIMEOUT
  MONGODB_SSL
  MONGODB_SSL_CERT_REQUIRED
  MONGODB_SSL_MATCH_HOSTNAME
  MONGODB_TLS
  MONGODB_TLS_ALLOW_INVALID_CERT
  MONGODB_TLS_ALLOW_INVALID_HOSTNAME
  MONGODB_TLS_CA_FILE
  MONGODB_TLS_CERTIFICATE_SELECTOR
  MONGODB_TLS_CERT_KEY_FILE
  MONGODB_TLS_CERT_KEY_FILE_PASSWORD
  MONGODB_TLS_CRL_FILE
  MONGODB_TZ_AWARE
  MONGODB_URI
  MONGODB_USERNAME
  MONGODB_WAIT_QUEUE_MULTIPLE
  MONGODB_WAIT_QUEUE_TIMEOUT
  P01_CDN_RECIPE_PROCESS


tear down
---------

  >>> from m01.mongo import clearThreadLocalCache
  >>> clearThreadLocalCache()

As you can see our cache items get removed:

  >>> from m01.mongo import LOCAL
  >>> pprint(LOCAL.__dict__)
  {}

Shutdown executors:

  >>> client.close()
  >>> _shutdown_executors()
