Exemplo n.º 1
0
    def find_account_by_id(cls, user_id):
        if not user_id:
            return None

        session = DbSessionFactory.create_session()

        account = session.query(Account) \
            .filter(Account.id == user_id) \
            .first()

        return account
Exemplo n.º 2
0
    def create_account(username, plain_text_password):
        session = DbSessionFactory.create_session()

        account = Account()
        account.username = username
        account.password_hash = AccountService.hash_text(plain_text_password)

        session.add(account)
        session.commit()

        return account
Exemplo n.º 3
0
    def get_params_by_history_id(lookup_id):
        ''' return parameters from an old search to seed new crawl'''

        session = DbSessionFactory.create_session()

        history = session.query(History) \
            .filter(History.auto_id == lookup_id) \
            .first()

        return dict(url=history.url,
                    search_type=history.search_type,
                    search_limit=history.search_limit,
                    keyword=history.keyword)
Exemplo n.º 4
0
    def find_account_by_username(cls, username):

        if not username or not username.strip():
            return None

        username = username.lower().strip()

        session = DbSessionFactory.create_session()

        account = session.query(Account) \
            .filter(Account.username == username) \
            .first()

        return account
Exemplo n.º 5
0
    def add_history(user_id, url, search_type, search_limit, keyword):
        ''' add valid parameters that a user crawled for'''
        session = DbSessionFactory.create_session()

        history = History()
        history.user_id = user_id
        history.url = url
        history.search_type = search_type
        history.search_limit = search_limit
        history.keyword = keyword

        session.add(history)
        session.commit()

        return history.auto_id