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 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): 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)