import pokedex.db
import pokedex.db.tables as tables
import pokedex.formulae
-from pokedex.savefile import PokemonSave
+from pokedex.struct import SaveFilePokemon
from pylons import config, request, response, session, tmpl_context as c, url
-from pylons.controllers.util import abort, redirect_to
+from pylons.controllers.util import abort, redirect
from sqlalchemy import and_, or_, not_
from sqlalchemy.orm import aliased, contains_eager, eagerload, eagerload_all, join
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.sql import func
+from sqlalchemy.exc import IntegrityError
from spline.model import meta
from spline.lib.base import BaseController, render
.one()
# We've got one! Cool, send it back. The game will ask us to
# delete it after receiving successfully
- pokemon_save = PokemonSave(stored_pokemon.pokemon_blob)
+ pokemon_save = SaveFilePokemon(stored_pokemon.pokemon_blob)
return pokemon_save.as_encrypted
except:
try:
# The uploaded Pokémon is encrypted, which is not very useful
- pokemon_save = PokemonSave(data, encrypted=True)
+ pokemon_save = SaveFilePokemon(data, encrypted=True)
# Create a record...
stored_pokemon = gts_model.GTSPokemon(
meta.Session.add(stored_pokemon)
meta.Session.commit()
return '\x01\x00'
- except:
- # If that failed (presumably due to unique key collision), we're
- # already storing something. Reject!
+ except IntegrityError:
+ # If that failed due to unique key collision, we're already storing
+ # something. Reject!
return '\x0c\x00'
def page_post_finish(self, pid, data):