1. Monwara LLC
  2. Untitled project
  3. PyMSTranslator


Branko Vukelic  committed e2ff54a

Added tips for Django

  • Participants
  • Parent commits ce9b153
  • Branches master

Comments (0)

Files changed (1)

File README.rst

View file
     >>> from mstranslator import MSTranslatorAccessKey
     >>> key = MSTranslatorAccessKey(client_id, client_secret)
+In Django, for example, you may create the key in the settings module, and make
+it available as a configuration setting::
+    # setup.py
+    import os
+    CLIENT_ID = os.environ.get('TRANSLATOR_ID')
+    CLIENT_SECRET = os.environ.get('TRANSLATOR_SECRET')
+    # somewhere in your view
+    from django.conf import settings
+    key = settings.MS_TRANSLATOR_KEY
+The key object has a ``get_key`` method which returns the cached key if it has
+not expired yet, shortening the response time. This method is used by the
+client object to retrieve the cached key, so you don't need to worry about the
+internal implementation.
 Creating the Microsoft Translator client object