def parse(self, params, path_info, host, post_data, request_method): self.host = host try: self.get_layer(path_info, params) except NoLayerException: a = Action() if params.has_key('service') and params['service'] == 'WFS': for layer in self.service.datasources: self.datasources.append(layer) if params.has_key('request'): a.request = params['request'] else: a.request = "GetCapabilities" else: a.method = "metadata" self.actions.append(a) return wfsrequest = WFSRequest() Request.parse(self, params, path_info, host, post_data, request_method, format_obj=wfsrequest)
def parse(self, params, path_info, host, post_data, request_method): try: self.get_layer(path_info, params) except NoLayerException: action = Action() action.method = "metadata" self.host = host self.actions.append(action) return Request.parse(self, params, path_info, host, post_data, request_method)
def handle_post(self, params, path_info, host, post_data, request_method): import xml.dom.minidom as m actions = [] id = self.get_id_from_path_info(path_info) if id: action = Action() action.method = "update" action.id = id doc = m.parseString(post_data) entry = doc.getElementsByTagName("Placemark")[0] feature = self.entry_to_feature(entry) action.feature = feature actions.append(action) else: doc = m.parseString(post_data) entries = doc.getElementsByTagName("Placemark") entries.reverse() for entry in entries: action = Action() action.method = "create" feature_obj = self.entry_to_feature(entry) action.feature = feature_obj actions.append(action) return actions
def handle_post(self, params, path_info, host, post_data, request_method): actions = [] id = self.get_id_from_path_info(path_info) if id: action = Action() action.method = "update" action.id = id try: feature_dict = simplejson.loads(post_data) except: raise Exception("Invalid JSON. Content was: %s" % post_data) if feature_dict.has_key("features"): feature_dict = feature_dict['features'][0] elif feature_dict.has_key("members"): feature_dict = feature_dict['members'][0] feature = self.createFeature(feature_dict, action.id) action.feature = feature actions.append(action) else: feature_data = simplejson.loads(post_data) if feature_data.has_key("features"): feature_data = feature_data['features'] elif feature_data.has_key("members"): feature_data = feature_data['members'] else: feature_data = [feature_data] for feature in feature_data: action = Action() action.method = "create" action.feature = self.createFeature(feature) actions.append(action) return actions
def insertUnique(self, feature): if not feature.properties.has_key(self.unique): raise Exception("Unique key (%s) missing from feature." % self.unique) action = Action() action.attributes[self.unique] = feature.properties[self.unique] features = self.select(action) if len(features) > 1: raise Exception( "There are two features with the unique key %s. Something's wrong with that." % feature.properties[self.unique]) thunk = self.freeze_feature(feature) if len(features) == 0: return self.append(thunk) else: self.db[features[0].id] = thunk return features[0].id
def handle_post(self, params, path_info, host, post_data, request_method): import xml.dom.minidom as m actions = [] id = self.get_id_from_path_info(path_info) if id: action = Action() action.method = "update" action.id = id doc = m.parseString(post_data) entries = doc.getElementsByTagName("entry") if not entries: entries = doc.getElementsByTagName("item") entry = entries[0] feature = self.entry_to_feature(entry) action.feature = feature if feature: actions.append(action) else: try: doc = m.parseString(post_data) except Exception, E: raise Exception("Unable to parse GeoRSS. (%s)\nContent was: %s" % (E, post_data)) entries = doc.getElementsByTagName("entry") if not entries: entries = doc.getElementsByTagName("item") entries.reverse() for entry in entries: action = Action() action.method = "create" feature_obj = self.entry_to_feature(entry) action.feature = feature_obj if feature_obj: actions.append(action)