mysociety/popit-api — pull request #16 by hecticjeff (2013-11-25 09:10:46+00:00)
Title: Handle long instance slugs

Allows popit-api to handle long instance names and map then to the underlying database by hashing the hostname. If the slug is < 64 characters then it will not be touched by this change, so old database instances that were previously created will carry on working correctly. When a new instance is created, if the slugified version of the instance hostname is > 63 characters then this code will convert it so it's exactly 63 characters long by shortening the slug and appending a hash to it.

So, for example, the hostname `cores-por-antartica-chilena-con-mucho-frio.popit.votainteligente.org` maps to the slug `popit-api-cores-por-antartica-chilena-con-mucho-frio-popit-votainteligente-org` when using the hostName storageSelector, which will then map to the database name `popit-api-cores-por-antartica--aec65846b4e17b4b5cfd7be23b769ae2`.

Fixes https://github.com/mysociety/popit/issues/254