Skip to content

Commit

Permalink
Merge pull request #155 from marian-vignau/UpdateDependencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
facundobatista authored Jun 22, 2024
2 parents b1c35bb + b292c8b commit 2e5e78c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
13 changes: 7 additions & 6 deletions kilink/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import zlib

from sqlalchemy import Column, DateTime, String, LargeBinary
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import declarative_base
from sqlalchemy.orm import sessionmaker, scoped_session

from kilink.config import config, DB_ENGINE_INSTANCE_KEY
Expand Down Expand Up @@ -97,7 +97,8 @@ def session_manager(orig_func):

def new_func(self, *a, **k):
"""Wrappend function to manage DB session."""
self.session.begin()
if not self.session.in_transaction():
self.session.begin()
try:
resp = orig_func(self, *a, **k)
self.session.commit()
Expand All @@ -121,7 +122,7 @@ def session(self):
if self._session is None:
db_engine = config[DB_ENGINE_INSTANCE_KEY]
Base.metadata.create_all(db_engine)
Session = scoped_session(sessionmaker(autocommit=True))
Session = scoped_session(sessionmaker())
self._session = Session(bind=db_engine)

return self._session
Expand Down Expand Up @@ -149,7 +150,7 @@ def create_kilink(self, content, text_type):
def update_kilink(self, parent_id, new_content, text_type):
"""Add a new child to a kilink."""
self._check_kilink(new_content)
parent_klnk = self.session.query(Kilink).get(parent_id)
parent_klnk = self.session.get(Kilink, parent_id)
if parent_klnk is None:
raise KilinkNotFoundError("Parent kilink not found")

Expand All @@ -166,7 +167,7 @@ def _check_kilink(self, content):
@session_manager
def get_kilink(self, linkode_id):
"""Get a specific kilink."""
klnk = self.session.query(Kilink).get(linkode_id)
klnk = self.session.get(Kilink, linkode_id)
if klnk is None:
raise KilinkNotFoundError("Data not found for kilink=%r" % (linkode_id,))
return klnk
Expand All @@ -188,7 +189,7 @@ def _get_kilink_tree(self, root):
@session_manager
def _get_root_node(self, linkode_id):
"""Return the root node of the kilink."""
klnk = self.session.query(Kilink).get(linkode_id)
klnk = self.session.get(Kilink, linkode_id)
if klnk is None:
raise KilinkNotFoundError("Kilink id not found: %r" % (linkode_id,))
return klnk
Expand Down
14 changes: 7 additions & 7 deletions kilink/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
app.config["STATIC_ROOT"] = 'static'
app.config["PROPAGATE_EXCEPTIONS"] = False

babel = Babel(app)

def get_locale():
"""Return the best matched language supported."""
return request.accept_languages.best_match(LANGUAGES.keys())


babel = Babel(app, locale_selector=get_locale)
cors = CORS(app)

# logger
Expand All @@ -41,12 +47,6 @@ def handle_content_data_too_big_error(error):
return jsonify({'message': error.message}), 413


@babel.localeselector
def get_locale():
"""Return the best matched language supported."""
return request.accept_languages.best_match(LANGUAGES.keys())


# -- main root view and accessory pages

@app.route('/')
Expand Down
9 changes: 4 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
flask==2.0.2
flask-cors==3.0.10
flask-babel==2.0.0
sqlalchemy==1.4.26
flask==3.0.3
flask-cors==4.0.1
flask-babel==4.0.0
sqlalchemy==2.0.31
pyyaml==6.0.1
werkzeug==2.0.3 # until we get flask updated

0 comments on commit 2e5e78c

Please sign in to comment.