def GET(self, map_name, format): mf = get_mapfile(map_name) return {"styles": [{ "name": os.path.basename(os.path.basename(s_name)), "href": "%s/maps/%s/styles/%s.%s" % (web.ctx.home, map_name, os.path.basename(s_name), format) } for s_name in tools.iter_styles(mf)] }
def POST(self, map_name, format): mf = get_mapfile(map_name) params = web.input(name=None) name = params.name if name == None: raise webapp.BadRequest(message="no parameter 'name' given.") with webapp.mightConflict(message="style {exception} already exists."): if name in tools.iter_styles(mf): raise webapp.KeyExists(name) data = web.data() path = tools.mk_style_path(name) with open(path, "w") as f: f.write(data)