$ pip install htg-url-generator
INSTALLED_APPS = [
...
'htg_url',
...
]
3. Declare a new 'AbstractHtgUrlGenerator' wrapper class and override 'create_unique_identifier' method:
class ExampleGeneratorClass(AbstractHtgUrlGenerator):
@staticmethod
def create_unique_identifier(**properties):
...
Include
custom
implementation
...
Return value for the 'create_unique_identifier' method should be a string
4. Declare a new 'AbstractFetchDataFromSap' wrapper class and override 'create_unique_identifier' method:
class ExampleFetcherCLass(AbstractFetchDataFromSap):
@staticmethod
def fetch_document_from_sap(**properties):
...
Include
custom
implementation
...
Return value for the 'fetch_document_from_sap' method should be a base64 encoded string or None
class ExampleDownloadDocumentView(AbstractDownloadDocumentView):
pass
By default 'AbstractDownloadDocumentView' class does NOT require login or any permission. Override if necessary
path('document/<token>/', ExampleDownloadDocumentView.as_view())
HTG_URL_SETTINGS = {
'HTG_URL_REDIS_TTL': 3600, # 60 minutes
'HTG_WRAPPER_CLASS': 'app_name.file_name.class_name',
'DOC_WRAPPER_CLASS': 'app_name.file_name.class_name'
'REDIS_CONNECTION_STRING': 'redis_connection_string' or None
}
$ python manage.py test htg_url
Package will use connection string to connect to Redis if it is defined in settings
under 'REDIS_CONNECTION_STRING'. Otherwise it will initialize connection using environment variables (see below)
Package expects you to have 'REDIS_HOST', 'REDIS_PORT', 'REDIS_PASSWORD'
and 'CACHE_REDIS_DB' (db index) environment variables as follows:
host = os.environ.get('REDIS_HOST')
port = int(os.environ.get('REDIS_PORT'))
password = os.environ.get('REDIS_PASSWORD')
os.environ.get('CACHE_REDIS_DB')
Package also expects you to have 'libmagic' installed
on your machine as 'python-magic' library depends on it:
$ sudo apt-get install libmagic1