parent=Scorelist.single_key()) except Exception, e: logging.error( "Score.submit: Got exception when creating Score " \ + "model object. Type: %s, msg: %s", type( e ), e ) return Score.SUBMIT_FAIL try: new_score.put() except Exception, e: logging.error( "Score.submit: Got exception when putting score " \ + "to the datastore. Type: %s, msg: %s", type( e ), e ) return Score.SUBMIT_FAIL # Save the location of the submit. try: Country.save( location ) except Exception, msg: logging.warning( "Score.submit: Got exception when saving " \ + "location: '%s'", msg ) cls._delete_cached_list_if_invalid( control, location, points ) cls._delete_cached_list_if_invalid( control, config.LOCATION_WORLD, points ) cls._delete_cached_list_if_invalid( control, config.LOCATION_WEEK, points ) return Score.SUBMIT_SUCCESS @classmethod def _already_exists( cls, name, comment, points, control ): scores = Score.all().ancestor(Scorelist.single_key()) \
altname=altname, lat=lat, lon=lon) elif featurecode in valid_states: loc = State(name=name, country=country, altname=altname, lat=lat, lon=lon) print loc.name else: loc = City(name=name, country=country, state=region, altname=altname, lat=lat, lon=lon) loc.save(pipe) except Exception, e: # logging.error("Could not import line %s: %s" % (row, e)) logging.error("Could not import a line") i += 1 if i % 1000 == 0: pipe.execute() pipe.execute() logging.info("Imported %d locations" % i) return True