From 2843e14dc33e6b74db5fd7f26906c8e65e24b53e Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 20 Apr 2011 02:46:37 -0400 Subject: [PATCH] Made the form display on the setup view display the function's docstring by default --- apps/documents/conf/settings.py | 15 ++++++++++++--- apps/main/views.py | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/documents/conf/settings.py b/apps/documents/conf/settings.py index af47ce2654..1bb83b76f5 100644 --- a/apps/documents/conf/settings.py +++ b/apps/documents/conf/settings.py @@ -10,6 +10,16 @@ from common.utils import proper_name from storage.backends.filebasedstorage import FileBasedStorage + +def default_checksum(x): + """hashlib.sha256(x).hexdigest()""" + return hashlib.sha256(x).hexdigest() + + +def default_uuid(): + """unicode(uuid.uuid4())""" + return unicode(uuid.uuid4()) + default_available_functions = { 'current_date':datetime.datetime.now().date, } @@ -22,7 +32,6 @@ available_transformations = { 'rotate': {'label':_(u'Rotate [degrees]'), 'arguments':[{'name':'degrees'}]} } - available_indexing_functions = { 'proper_name': proper_name } @@ -42,8 +51,8 @@ UNCOMPRESS_COMPRESSED_LOCAL_FILES = getattr(settings, 'DOCUMENTS_UNCOMPRESS_COMP UNCOMPRESS_COMPRESSED_STAGING_FILES = getattr(settings, 'DOCUMENTS_UNCOMPRESS_COMPRESSED_STAGING_FILES', True) # Saving -CHECKSUM_FUNCTION = getattr(settings, 'DOCUMENTS_CHECKSUM_FUNCTION', lambda x: hashlib.sha256(x).hexdigest()) -UUID_FUNCTION = getattr(settings, 'DOCUMENTS_UUID_FUNCTION', lambda:unicode(uuid.uuid4())) +CHECKSUM_FUNCTION = getattr(settings, 'DOCUMENTS_CHECKSUM_FUNCTION', default_checksum) +UUID_FUNCTION = getattr(settings, 'DOCUMENTS_UUID_FUNCTION', default_uuid) # Storage STORAGE_BACKEND = getattr(settings, 'DOCUMENTS_STORAGE_BACKEND', FileBasedStorage) diff --git a/apps/main/views.py b/apps/main/views.py index dc399146d9..a0bffc6d0c 100644 --- a/apps/main/views.py +++ b/apps/main/views.py @@ -120,7 +120,7 @@ def check_settings(request): def _return_type(value): if isinstance(value, types.FunctionType): - return _(u'function found') + return value.__doc__ if value.__doc__ else _(u'function found') elif isinstance(value, types.ClassType): return _(u'class found: %s') % unicode(value).split("'")[1].split('.')[-1] elif isinstance(value, types.TypeType):