Exemple #1
0
def identity_by_identifier(identifier):
    try:
        return session.query(Identity).filter(Identity.identifier == identifier).first()
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to select identity for identifier")
Exemple #2
0
def purchase(id):
  try:
    return session.query(Purchase).filter(Purchase.id == id).one()
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to select purchase")
Exemple #3
0
def purchase_for_user_app(userid, appid):
    try:
        return session.query(Purchase).filter(Purchase.user_id == userid).filter(Purchase.app_id == appid).first()
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to select purchases for user")
Exemple #4
0
def purchase_for_user_app(userid, appid):
  try:
    return session.query(Purchase).filter(Purchase.user_id == userid).filter(Purchase.app_id == appid).first()
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to select purchases for user")
Exemple #5
0
def application(id):
    try:
        return session.query(Application).filter(Application.id == int(id)).one()
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to select application")
Exemple #6
0
def applications():
    try:
        return session.query(Application).all()
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to select applications")
Exemple #7
0
def createApplication(manifestText, manifestSrc, manifestObj = None):
  try:
    if not manifestObj:
      manifestObj = json.loads(manifestSrc)
      
    name = manifestObj['name']
    baseURL = manifestObj['base_url']
    icon96 = None
    if 'icons' in manifestObj:
      if '96' in manifestObj['icons']:
        icon96 = manifestObj['icons']['96']
      else:
        key = manifestObj['icons'].keys()[0]
        icon96 = manifestObj['icons'][key]

    description = manifestObj['description']

    a = Application(name, manifestSrc, manifestText, baseURL, datetime.now(), icon96, description)
    session.add(a)
    session.commit()
    return a

  except sqlalchemy.exc.IntegrityError:
    session.rollback()
    raise ValueError("An application is already registered for that launch URL.")
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to create application")
Exemple #8
0
def applications():
  try:
    return session.query(Application).all()
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to select applications")
Exemple #9
0
def application(id):
  try:
    return session.query(Application).filter(Application.id == int(id)).one()
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to select application")
Exemple #10
0
def identity_by_identifier(identifier):
  try:
    return session.query(Identity).filter(Identity.identifier == identifier).first()
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to select identity for identifier")
Exemple #11
0
def createApplication(manifestText, manifestSrc, manifestObj=None):
    try:
        if not manifestObj:
            manifestObj = json.loads(manifestSrc)

        name = manifestObj["name"]
        baseURL = manifestObj["base_url"]
        icon96 = None
        if "icons" in manifestObj:
            if "96" in manifestObj["icons"]:
                icon96 = manifestObj["icons"]["96"]
            else:
                key = manifestObj["icons"].keys()[0]
                icon96 = manifestObj["icons"][key]

        description = manifestObj["description"]

        a = Application(name, manifestSrc, manifestText, baseURL, datetime.now(), icon96, description)
        session.add(a)
        session.commit()
        return a

    except sqlalchemy.exc.IntegrityError:
        session.rollback()
        raise ValueError("An application is already registered for that launch URL.")
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to create application")
Exemple #12
0
def user(id):
  try:
    return session.query(User).filter(User.id == id).first()
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to select user")
Exemple #13
0
def user(id):
    try:
        return session.query(User).filter(User.id == id).first()
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to select user")
Exemple #14
0
def purchase(id):
    try:
        return session.query(Purchase).filter(Purchase.id == id).one()
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to select purchase")
Exemple #15
0
def remove_purchase_for_user_app(userid, appid):
  try:
    session.query(Purchase).filter(Purchase.user_id == userid).filter(Purchase.app_id == appid).delete()
    session.commit()
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to remove purchase")
Exemple #16
0
def save(obj):
  try:
    session.add(obj)
    session.commit()
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to save object")
Exemple #17
0
def remove_purchase_for_user_app(userid, appid):
    try:
        session.query(Purchase).filter(Purchase.user_id == userid).filter(Purchase.app_id == appid).delete()
        session.commit()
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to remove purchase")
Exemple #18
0
def save(obj):
    try:
        session.add(obj)
        session.commit()
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to save object")
Exemple #19
0
def categories(parent=None):
  try:
    q = session.query(Category)
    if parent: q = q.filter(Category.parent_id == parent)
    return q.all()
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to select categories")
Exemple #20
0
def categories(parent=None):
    try:
        q = session.query(Category)
        if parent:
            q = q.filter(Category.parent_id == parent)
        return q.all()
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to select categories")
Exemple #21
0
def createPurchaseForUserApp(uid, appid):
  try:
    p = Purchase(uid, appid, datetime.now())
    session.add(p)
    session.commit()
    return p

  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to create purchase")
Exemple #22
0
def createCategory(name, parent=None):
    try:
        if parent and (len(parent) == 0 or parent == 0):
            parent = None
        c = Category(name, parent=parent)
        session.add(c)
        session.commit()
        return c
    except Exception, e:
        session.rollback()
        raise ValueError("Error while creating category: %s" % e)
Exemple #23
0
def addIdentity(uid, identifier, displayName, email):
  try:
    id = Identity(uid, identifier, displayName, email, datetime.now())
    session.add(id)
    session.commit()
    return id

  except sqlalchemy.exc.IntegrityError, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to create identity")
Exemple #24
0
def createCategory(name, parent=None):
  try:
    if parent and (len(parent) == 0 or parent == 0):
        parent = None
    c = Category(name, parent=parent)
    session.add(c)
    session.commit()
    return c
  except Exception, e:
    session.rollback()
    raise ValueError("Error while creating category: %s" % e)
Exemple #25
0
def createPurchaseForUserApp(uid, appid):
    try:
        p = Purchase(uid, appid, datetime.now())
        session.add(p)
        session.commit()
        return p

    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to create purchase")
Exemple #26
0
def addIdentity(uid, identifier, displayName, email):
    try:
        id = Identity(uid, identifier, displayName, email, datetime.now())
        session.add(id)
        session.commit()
        return id

    except sqlalchemy.exc.IntegrityError, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to create identity")
Exemple #27
0
def createUser():
  try:
    u = User()
    session.add(u)
    session.commit()
    return u

  except sqlalchemy.exc.IntegrityError, e:
    logging.exception(e)  
    session.rollback()
    raise ValueError("Unable to create user")
Exemple #28
0
def createUser():
    try:
        u = User()
        session.add(u)
        session.commit()
        return u

    except sqlalchemy.exc.IntegrityError, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to create user")
Exemple #29
0
def bing_user():
    try:
        # 判断是否登陆,登陆了session中包含ADMIN_EMAIL键
        if config.ADMIN_UUID in session:
            admin_email = session.get(config.ADMIN_UUID)
            admin_user = db_session.query(Admin).filter(
                Admin.admin_email == admin_email).first()
            # 如果从数据库中查询到了user用户(以防存在假的cookie, 概率几乎没有)
            if admin_user:
                g.admin_user = admin_user
    except Exception as err:
        db_session.rollback()
Exemple #30
0
def delete_user(id):
    try:
        user = session.query(Employee).get(id)
        user2 = session.query(Skills).filter_by(emp_id=id).first()
        #if user user2  !=None:
        session.delete(user)
        session.delete(user2)
        session.commit()
        final = {"firstname": user.firstname, "lastname": user.lastname}
        return final
    except Exception as e:
        return e
        session.rollback()
Exemple #31
0

def createUser():
    try:
        u = User()
        session.add(u)
        session.commit()
        return u

    except sqlalchemy.exc.IntegrityError, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to create user")
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to create application")


def user(id):
    try:
        return session.query(User).filter(User.id == id).first()
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to select user")


def addIdentity(uid, identifier, displayName, email):
    try:
        id = Identity(uid, identifier, displayName, email, datetime.now())
Exemple #32
0
    
    
def createUser():
  try:
    u = User()
    session.add(u)
    session.commit()
    return u

  except sqlalchemy.exc.IntegrityError, e:
    logging.exception(e)  
    session.rollback()
    raise ValueError("Unable to create user")
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to create application")

def user(id):
  try:
    return session.query(User).filter(User.id == id).first()
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to select user")
    

def addIdentity(uid, identifier, displayName, email):
  try:
    id = Identity(uid, identifier, displayName, email, datetime.now())
    session.add(id)