Skip to content
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

Binding DB sessions based on SQLAlchemy 1, changing how to declare Base Model classes, and other code modernization #5

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased](https://github.com/python-social-auth/social-app-flask-sqlalchemy/commits/master)

### Changed
- Modified model and access code to work with SQLAlchemy version 2 (Issue #3)
- Updated packaging information files per PEP 517, PEP 518 (Issue #4)
- Restricted Python minimum working version to 3.7 or higher to align with SQLAlchemy 2 (Issue #3)

## [1.0.1](https://github.com/python-social-auth/social-app-flask-sqlalchemy/releases/tag/1.0.1) - 2017-01-29

### Added
Expand Down
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
build:
@ python setup.py sdist
@ python setup.py bdist_wheel --python-tag py2
@ BUILD_VERSION=3 python setup.py bdist_wheel --python-tag py3
@ python -m build

publish:
@ python setup.py sdist upload
@ python setup.py bdist_wheel --python-tag py2 upload
@ BUILD_VERSION=3 python setup.py bdist_wheel --python-tag py3 upload
@ twine upload dist/*

clean:
@ find . -name '*.py[co]' -delete
Expand Down
55 changes: 55 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = 'social-auth-app-flask-sqlalchemy'
dynamic = ["version"]
dependencies = [
"six",
"sqlalchemy",
"social-auth-core>=1.0.0",
"social-auth-app-flask>=1.0.0",
"social-auth-storage-sqlalchemy>=1.0.1",
]
authors = [
{name = "Matias Aguirre", email = "matiasaguirre@gmail.com"},
{name = "Lee Ji-ho", email = "search5@gmail.com"},
]
description = 'Python Social Authentication, SQLAlchemy Flask models integration.'
license = {text = 'BSD'}
keywords = ["flask", "sqlalchemy", "social auth"]
readme = "README.md"
classifiers=[
'Development Status :: 4 - Beta',
'Topic :: Internet',
'License :: OSI Approved :: BSD License',
'Intended Audience :: Developers',
'Environment :: Web Environment',
'Programming Language :: Python',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12'
]
requires-python = ">= 3.7"

[project.urls]
Repository = 'https://github.com/python-social-auth/social-app-flask-sqlalchemy'
Documentation = 'http://python-social-auth.readthedocs.org'
Issues = 'https://github.com/python-social-auth/social-app-flask-sqlalchemy/issues'
Changelog = 'https://github.com/python-social-auth/social-app-flask-sqlalchemy/blob/master/CHANGELOG.md'

[options]
zip_safe = false

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages]
find = {}

[tool.setuptools.dynamic]
version = {attr = "social_flask_sqlalchemy.__version__"}
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

11 changes: 0 additions & 11 deletions setup.cfg

This file was deleted.

37 changes: 0 additions & 37 deletions setup.py

This file was deleted.

14 changes: 6 additions & 8 deletions social_flask_sqlalchemy/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Flask SQLAlchemy ORM models for Social Auth"""
from sqlalchemy import Column, String, ForeignKey
from sqlalchemy.orm import relationship, backref
from sqlalchemy import String, ForeignKey
from sqlalchemy.orm import relationship, backref, Mapped, mapped_column, DeclarativeBase
from sqlalchemy.schema import UniqueConstraint
from sqlalchemy.ext.declarative import declarative_base

from social_core.utils import setting_name, module_member
from social_sqlalchemy.storage import SQLAlchemyUserMixin, \
Expand All @@ -13,7 +12,8 @@
BaseSQLAlchemyStorage


PSABase = declarative_base()
class PSABase(DeclarativeBase):
pass


class _AppSession(PSABase):
Expand All @@ -32,7 +32,6 @@ class UserSocialAuth(_AppSession, SQLAlchemyUserMixin):
"""Social Auth association model"""
# Temporary override of constraints to avoid an error on the still-to-be
# missing column uid.
__table_args__ = ()

@classmethod
def user_model(cls):
Expand Down Expand Up @@ -77,8 +76,7 @@ def init_social(app, session):
User = module_member(app.config[setting_name('USER_MODEL')])
_AppSession._set_session(session)
UserSocialAuth.__table_args__ = (UniqueConstraint('provider', 'uid'),)
UserSocialAuth.uid = Column(String(UID_LENGTH))
UserSocialAuth.user_id = Column(User.id.type, ForeignKey(User.id),
nullable=False, index=True)
UserSocialAuth.user_id = mapped_column(ForeignKey(User.id),
nullable=False, index=True)
UserSocialAuth.user = relationship(User, backref=backref('social_auth',
lazy='dynamic'))