def store_file(self, path, **kwargs): abs_path = os.path.abspath(path) fh = open(abs_path, 'r') feature = geojson.load(fh) props = feature.get('properties', {}) id = props.get('wof:id', None) if id == None: raise Exception, "E_INSUFFICIENT_WHOSONFIRST" rel_path = utils.id2relpath(id) if kwargs.get("prefix", None): rel_path = os.path.join(kwargs['prefix'], rel_path) logging.debug("copy %s to %s:%s" % (abs_path, self.bucket, rel_path)) k = Key(self.bucket) k.key = rel_path k.set_contents_from_filename(abs_path) acl = kwargs.get('acl', 'public-read') k.set_acl(acl) # print k.generate_url(expires_in=0, query_auth=False) return True
def enresponsify(rsp): features = [] for feature in rsp: props = feature['properties'] id = props['wof:id'] path = utils.id2relpath(id) props['wof:path'] = path feature['properties'] = props features.append(feature) rsp = {'type': 'FeatureCollection', 'features': features} return flask.jsonify(rsp)