8000 Avoiding "python-openid" dependency when using "Webapp2Session" · Issue #67 · authomatic/authomatic · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Avoiding "python-openid" dependency when using "Webapp2Session" #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fabito opened this issue Nov 24, 2014 · 2 comments
Open

Avoiding "python-openid" dependency when using "Webapp2Session" #67

fabito opened this issue Nov 24, 2014 · 2 comments
Milestone

Comments

@fabito
Copy link
fabito commented Nov 24, 2014

Hi,

When I started using the Webapp2Session implementation I had to add the python-openid dependency because NDBOpenIDStore depends on it.
How could we decouple both components so that we can prevent import a new unnecessary dependency ?

thanks in advance
Fábio

@peterhudec
Copy link
Member

Yes, the extras.gae module imports from extras.gae.openid which imports from openid, which is not good and it's only because the extras.gae.NDBConfig uses the extras.gae.openid.NDBOpenIDStore as openid store by default.

I think the best solution will be to set the openid store explicitly when NDBConfig is initialized.

@peterhudec peterhudec added this to the 0.0.10 milestone Nov 25, 2014
@fabito
Copy link
Author

I was just reading the code and to be honest I still didn't understand why do we need NDBOpenIDStore within NDBConfig.

Anyways, we could also have 2 separate modules inside "extras" package:

  • webapp2 and
  • config / ndb

Or move the NDBConfig import from the top to the "get" method:

    @classmethod
    def get(cls, key, default=None):
        """
        Resembles the :meth:`dict.get` method.

        :returns:
            A configuration dictionary for specified provider.
        """

        # Query datastore.
        result = cls.query(cls.provider_name == key).get()

        if result:
            result_dict = result.to_dict()

            # Use NDBOpenIDStore by default
            from authomatic.extras.gae.openid import NDBOpenIDStore
            result_dict['store'] = NDBOpenIDStore

            # Convert coma-separated values to list. Currently only scope is csv.
            for i in ('scope', ):
                prop = result_dict.get(i)
                if prop:
                    result_dict[i] = [s.strip() for s in prop.split(',')]
                else:
                    result_dict[i] = None

            return result_dict
        else:
            return default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0