def sign_up(email, password):
    result = {}
    from Models import UserCredentials, UserDetails, Achievement

    def provision(_key):
        user_details = UserDetails(id=_key.id(), achievements=[])
        user_details.put()
    try:
        q = UserCredentials.gql("WHERE email = '" + str(email) + "'")
        user_creds = q.get()
        if user_creds is None:
            new_user = UserCredentials(email=email, password=password)
            key = new_user.put()
            user_id = str(key.id())
            provision(key)
            result["user_id"] = str(user_id)
            result["status_code"] = "200"
            return json.dumps(result)
        else:
            result["user_id"] = "null"
            result["status_code"] = "996"
            return json.dumps(result)
    except BaseException, ex:
        logging.exception('Something Bad Happened - %s' % ex)
        return "Exception: " + str(ex)
def sign_in(email, password):
    from Models import UserCredentials
    try:
        d = {}
        q = UserCredentials.gql("WHERE email = '" + email + "'")
        user = q.get()
        if user is None:
            d["user_id"] = ""
            d["status_code"] = "999"
            return json.dumps(d)
        if password != user.password:
            d["user_id"] = "null"
            d["status_code"] = "998"
            return json.dumps(d)
        d["user_id"] = str(user.key.id())
        d["status_code"] = "200"
        return json.dumps(d)
    except BaseException, ex:
        logging.exception('Something Bad Happened - %s' % ex)