Made the form display on the setup view display the function's docstring by default

This commit is contained in:
Roberto Rosario
2011-04-20 02:46:37 -04:00
parent e7c580f1a8
commit 2843e14dc3
2 changed files with 13 additions and 4 deletions

View File

@@ -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)

View File

@@ -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):