POST /mapfiles: Create a new item.

def create(self):
        """POST /mapfiles: Create a new item."""
        # get json content from POST request
        content = request.environ['wsgi.input'].read(int(request.environ['CONTENT_LENGTH']))
        #content = content.decode('utf8')   mapfile interface don't like unicode strings... bad...

        # load mapfile
        mapfile = Mapfile()
        dict = simplejson.loads(content)
        mapfile.from_dict(dict)

        # create mapfile
        mapname = mapfile.get_name()
        map_pathname = h.gen_mapname()
        mapfile.to_file(os.path.join(config['mapfiles_dir'], map_pathname))

        # create map in db
        map = self._new_map_from_user(c.user, mapname, map_pathname)

        response.status = 201

        href = h.url_for(controller="mapfiles", action="show", id=map.id)
        wmsproxyurl = h.url_for(controller='mapfiles', action='wms_proxy', id=map.id)
        wmsurl = "%s?%s" %(config['mapserver_url'], urlencode({'map':os.path.join(config['mapfiles_dir'], map.filepath)}))
        return {'name': map.name, 'id': map.id, 'href': href, 'wmsurl': wmsurl, 'wmsproxyurl': wmsproxyurl}