[ckan-discuss] lowercase file formats

David Read david.read at hackneyworkshop.com
Fri Mar 16 11:36:31 GMT 2012


I notice that file formats are now automatically changed to lower
case, whatever you type in. I can see this is useful to stop the
database ending up with both 'CSV' and 'csv', but I think capitals are
often important. e.g. our database has RDFa, iCal, netCDF, Flash
Player and having this hard-coded in the logic layer is a rather
inflexible. And what if on our site we'd prefer CSV to csv? Also, it
doesn't seem right to do this conversion without telling you *after*
you submit the form.

How about just having format autocomplete with some well-known
formats, or convert only well-known formats (e.g. csv, xls) to
lower/uppercase, rather than the whole lot?

Dave

commit da3edd4371e381c2a631578938e878a2cf612bd9
Author: Tom Rees <zephod at gmail.com>
Date:   Tue Feb 28 18:26:31 2012 +0000

    [#1506]: Force format field to be lowercase in resources.

diff --git a/ckan/lib/dictization/model_dictize.py b/ckan/lib/dictization/model_
index 309350e..1e1475e 100644
--- a/ckan/lib/dictization/model_dictize.py
+++ b/ckan/lib/dictization/model_dictize.py
@@ -79,6 +79,7 @@ def extras_list_dictize(extras_list, context):

 def resource_dictize(res, context):
     resource = table_dictize(res, context)
+    resource['format'] = resource.get('format','').lower()
     extras = resource.pop("extras", None)
     if extras:
         resource.update(extras)



More information about the ckan-discuss mailing list