okfn/ckan — pull request #1148 by joetsoi (2013-08-22 15:38:06+00:00)
Title: Strip trailing whitespaces in model's attributes

Trailing whitespaces are always (mostly?) user mistakes. They also break sorting if on the left (see [this issue on pdeu](https://github.com/okfn/ckanext-pdeu/issues/65)). To avoid headaches, we should strip them before saving the model to the DB.

A good way to implement it would be to create a new validator that simply does a ```strip()```, not complaining about anything. A problem with this approach is that, if we want to strip every string attribute in every model, it starts getting repetitive. An alternative would be to add this functionality to ```DomainObject.__init__```. This would make it available to every model, and make it easier to test, but it'll be a bit hidden.

Personally, I prefer the ```DomainObject``` alternative, but I'm OK with both.

When you do this, make sure you remove every place where we strip model's attributes (i.e. ```ckan/lib/search/index.py```)

/cc @joetsoi