Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 6
0
def applications():
    try:
        return session.query(Application).all()
    except Exception, e:
        logging.exception(e)
        session.rollback()
        raise ValueError("Unable to select applications")
Exemplo n.º 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")
Exemplo n.º 8
0
def applications():
  try:
    return session.query(Application).all()
  except Exception, e:
    logging.exception(e)
    session.rollback()
    raise ValueError("Unable to select applications")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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)
Exemplo n.º 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")
Exemplo n.º 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)
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 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())
Exemplo n.º 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)