def real_get(self): """ Handles /classify GET requests. A basic request with return a form setup for posting a new Classification. append '?noform=1' to the GET request and we return a comma seperated list of ID's The list of ClassIds sent in to the POST handler need to be in this order. """ if self.ts: ts = self.ts noform = self.request.REQUEST.get('noform') if noform: self.response.headers["Content-Type"] = "text/txt" ids = ts.ids if issubclass(type(ids),basestring): ids = TileSet_IDS.get_by_key_name(ids) ids = zlib.decompress(ids.ids) if noform=='json': json = '{"ids":"%s"}'%ids callback = self.request.REQUEST.get('callback') if callback: json = "%s(%s)"%(callback,json) return self.write(json) self.write(ids) else: tpath = os.path.join(os.path.dirname(__file__), 'templates/classify.html') self.write(template.render(tpath, {'ts_name':ts.name}))
def real_get(self): ts = self.ts if self.ts: ids = ts.ids.ids if issubclass(type(ids),basestring): ids = TileSet_IDS.get_by_key_name(ids) ids = zlib.decompress(ids) ids = ids.split(',') self.response.headers["Content-Type"] = "text/csv" self.write('RegionID,Value\n') self.write(''.join(['"%s",\n'%i for i in ids]))