<commit_before># -*- coding: utf-8 -*-
"""
    solace._openid_auth
    ~~~~~~~~~~~~~~~~~~~

    Implements a simple OpenID driven store.

    :copyright: (c) 2009 by Plurk Inc., see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement

from time import time
from hashlib import sha1
from contextlib import closing

from openid.association import Association
from openid.store.interface import OpenIDStore
from openid.consumer.consumer import Consumer, SUCCESS, CANCEL
from openid.consumer import discover
from openid.store import nonce

from sqlalchemy.orm import scoped_session
from sqlalchemy.exceptions import SQLError

from werkzeug import redirect
from werkzeug.exceptions import NotFound

from solace.i18n import _, lazy_gettext
from solace.application import url_for
from solace.templating import render_template
from solace.database import get_engine, session
from solace.schema import openid_association, openid_user_nonces
from solace.models import User
from solace.forms import OpenIDLoginForm, OpenIDRegistrationForm
from solace.auth import AuthSystemBase, LoginUnsucessful


class SolaceOpenIDStore(OpenIDStore):
    """Implements the open store for solace using the database."""

    def connection(self):
        return closing(get_engine().connect())

    def storeAssociation(self, server_url, association):
        with self.connection() as con:
            con.execute(openid_association.insert(),
                server_url=server_url,
                handle=association.handle,
                secret=association.secret.encode('base64'),
                issued=association.issued,
                lifetime=association.lifetime,
                assoc_type=association.assoc_type
            )

    def getAssociation(self, server_url, handle=None):
        filter = openid_association.c.server_url == server_url
        if handle is not None:
            filter &= openid_association.c.handle == handle
        with self.connection() as con:
            result = con.execute(openid_association.select(filter))<commit_msg>BUG: missing import. (transplanted from c9134cfda123e0a167df080f6e9b99943a7a2556)<commit_after># -*- coding: utf-8 -*-
"""
    solace._openid_auth
    ~~~~~~~~~~~~~~~~~~~

    Implements a simple OpenID driven store.

    :copyright: (c) 2009 by Plurk Inc., see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
"""
from __future__ import with_statement

from time import time
from hashlib import sha1
from contextlib import closing

from openid.association import Association
from openid.store.interface import OpenIDStore
from openid.consumer.consumer import Consumer, SUCCESS, CANCEL
from openid.consumer import discover
from openid.store import nonce

from sqlalchemy.orm import scoped_session
from sqlalchemy.exceptions import SQLError

from werkzeug import redirect
from werkzeug.exceptions import NotFound

from solace.i18n import _, lazy_gettext
from solace.application import url_for
from solace.templating import render_template
from solace.database import get_engine, session
from solace.schema import openid_association, openid_user_nonces
from solace.models import User
from solace.forms import OpenIDLoginForm, OpenIDRegistrationForm
from solace.auth import AuthSystemBase, LoginUnsucessful
from solace import settings


class SolaceOpenIDStore(OpenIDStore):
    """Implements the open store for solace using the database."""

    def connection(self):
        return closing(get_engine().connect())

    def storeAssociation(self, server_url, association):
        with self.connection() as con:
            con.execute(openid_association.insert(),
                server_url=server_url,
                handle=association.handle,
                secret=association.secret.encode('base64'),
                issued=association.issued,
                lifetime=association.lifetime,
                assoc_type=association.assoc_type
            )

    def getAssociation(self, server_url, handle=None):
        filter = openid_association.c.server_url == server_url
        if handle is not None:
            filter &= openid_association.c.handle == handle
        with self.connection() as con:
            result = con.execute(openid_association.select(filter))
{'fraction_non_alphanumeric': 0.07570831398049234, 'fraction_numerical': 0.010682768230376219, 'mean_word_length': 3.646170442286947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5411755', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1157, 'n_words': 346}