Skip to content

Commit

Permalink
Drop zope.sqlalchemy
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
  • Loading branch information
abompard committed Apr 12, 2024
1 parent 3027851 commit 63cea5b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 77 deletions.
45 changes: 3 additions & 42 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ pastedeploy = "^3.1.0"
pygments = "^2.17.2"
simplejson = "^3.19.2"
sqlalchemy = "^2.0.29"
zope-sqlalchemy = "^3.1"
arrow = "^1.3.0"
alembic = "^1.13.1"
fedora-messaging = "^3.5.0"
Expand Down
2 changes: 0 additions & 2 deletions tahrir_api/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
import arrow
import pygments
import simplejson
import zope.sqlalchemy
from sqlalchemy import Column, DateTime, ForeignKey, Unicode, UniqueConstraint
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, scoped_session, sessionmaker
from sqlalchemy.types import Boolean, Integer

DBSession = scoped_session(sessionmaker())
zope.sqlalchemy.register(DBSession)

DeclarativeBase = declarative_base()
DeclarativeBase.query = DBSession.query_property()
Expand Down
28 changes: 0 additions & 28 deletions tahrir_api/scripts/initializedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,3 @@ def main(argv=sys.argv):
engine = engine_from_config(settings, "sqlalchemy.")
DBSession.configure(bind=engine)
DeclarativeBase.metadata.create_all(engine)

return # Skip all the following... just leaving it for posterity

with transaction.manager:
issuer = Issuer(
name="Ralph Bean",
origin="http://badges.threebean.org",
org="threebean.org",
contact="rbean@redhat.com",
)
DBSession.add(issuer)
badge = Badge(
name="Plus One!",
image="/pngs/threebean-plus-one.png",
description="""
Got a recommendation from threebean for being awesome.
""".strip(),
criteria="/badges/plus-one", # TODO -- how should this work?
issuer=issuer,
)
DBSession.add(badge)
person = Person(email="rbean@redhat.com")
DBSession.add(person)
assertion = Assertion(badge=badge, person=person, issued_on=datetime.datetime.now())

DBSession.add(assertion)

pprint.pprint(assertion.__json__())
9 changes: 5 additions & 4 deletions tahrir_api/scripts/populateseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ def main(argv=sys.argv):
engine = engine_from_config(settings, "sqlalchemy.")
DBSession.configure(bind=engine)

with transaction.manager:
for badge in DBSession.query(Badge).all():
with DBSession() as session:
for badge in session.query(Badge).all():
if badge.milestone:
# Skip badges that already are in some series.
continue
series_name, ordering = get_series_name(badge.name)
if series_name and ordering:
series = DBSession.query(Series).filter(Series.name == series_name).first()
series = session.query(Series).filter(Series.name == series_name).first()

if not series:
print(
Expand All @@ -118,4 +118,5 @@ def main(argv=sys.argv):
milestone.badge_id = badge.id
milestone.position = ordering
milestone.series_id = series_name.lower().replace(" ", "-")
DBSession.add(milestone)
session.add(milestone)
session.commit()

0 comments on commit 63cea5b

Please sign in to comment.