Skip to content

Commit

Permalink
Fix import to use monkey patch early
Browse files Browse the repository at this point in the history
  • Loading branch information
varmar05 committed Nov 13, 2024
1 parent 7a6da0d commit 79e7a2b
Show file tree
Hide file tree
Showing 34 changed files with 33 additions and 40 deletions.
2 changes: 0 additions & 2 deletions server/mergin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Copyright (C) Lutra Consulting Limited
#
# SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial

from .app import db, mail, ma, create_app
2 changes: 1 addition & 1 deletion server/mergin/auth/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .commands import add_commands
from .config import Configuration
from .models import User, UserProfile
from .. import db
from ..app import db

# signal for other versions to listen to
user_account_closed = signal("user_account_closed")
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/auth/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from flask import Flask
from sqlalchemy import or_, func

from .. import db
from ..app import db
from .models import User, UserProfile


Expand Down
3 changes: 1 addition & 2 deletions server/mergin/auth/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
UserChangePasswordForm,
ApiLoginForm,
)
from .. import db
from ..app import DEPRECATION_API_MSG
from ..app import DEPRECATION_API_MSG, db
from ..utils import format_time_delta


Expand Down
2 changes: 1 addition & 1 deletion server/mergin/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from flask import current_app, request
from sqlalchemy import or_, func

from .. import db
from ..app import db
from ..sync.utils import get_user_agent, get_ip, get_device_id


Expand Down
3 changes: 1 addition & 2 deletions server/mergin/auth/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from flask import current_app
from marshmallow import fields

from .. import ma
from .models import User, UserProfile
from ..app import DateTimeWithZ
from ..app import DateTimeWithZ, ma


class UserProfileSchema(ma.SQLAlchemyAutoSchema):
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/auth/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sqlalchemy.sql.operators import isnot

from ..celery import celery
from .. import db
from .app import db
from .models import User
from .config import Configuration

Expand Down
2 changes: 1 addition & 1 deletion server/mergin/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from smtplib import SMTPException, SMTPServerDisconnected

from .config import Configuration
from . import mail
from .app import mail


# create on flask app independent object
Expand Down
3 changes: 1 addition & 2 deletions server/mergin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
# SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial

import os
from .version import get_version
from decouple import config, Csv

config_dir = os.path.abspath(os.path.dirname(__file__))
from .version import get_version


class Configuration(object):
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/stats/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import uuid
from sqlalchemy.dialects.postgresql import UUID

from .. import db
from ..app import db


class MerginInfo(db.Model):
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/sync/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from flask import Flask, current_app

from .files import UploadChanges
from .. import db
from ..app import db
from .models import Project, ProjectAccess, ProjectVersion
from .utils import split_project_path

Expand Down
2 changes: 1 addition & 1 deletion server/mergin/sync/db_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from flask import current_app, abort
from sqlalchemy import event

from .. import db
from ..app import db


def check(session):
Expand Down
3 changes: 1 addition & 2 deletions server/mergin/sync/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from marshmallow import fields, EXCLUDE, pre_load, post_load, post_dump
from pathvalidate import sanitize_filename

from .. import ma
from ..app import DateTimeWithZ
from ..app import DateTimeWithZ, ma


def mergin_secure_filename(filename: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/sync/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
ProjectFile,
)
from .storages.disk import move_to_tmp
from .. import db
from ..app import db
from .storages import DiskStorage
from .utils import is_versioned_file, is_qgis

Expand Down
2 changes: 1 addition & 1 deletion server/mergin/sync/private_api_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sqlalchemy.orm import defer
from sqlalchemy import text, and_, desc, asc

from .. import db
from ..app import db
from ..auth import auth_required
from ..auth.models import User, UserProfile
from .forms import AccessPermissionForm
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/sync/public_api_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from gevent import sleep
import base64
from werkzeug.exceptions import HTTPException
from .. import db
from ..app import db
from ..auth import auth_required
from ..auth.models import User
from .models import (
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/sync/public_api_v2_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from flask import abort, jsonify
from flask_login import current_user

from mergin import db
from mergin.app import db
from mergin.auth import auth_required
from mergin.sync.models import Project
from mergin.sync.permissions import ProjectPermissions, require_project_by_uuid
Expand Down
3 changes: 1 addition & 2 deletions server/mergin/sync/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
from flask_login import current_user
from flask import current_app

from .. import ma
from .files import ProjectFileSchema, FileSchema
from .permissions import ProjectPermissions
from .models import Project, ProjectVersion, AccessRequest, FileHistory, PushChangeType
from ..app import DateTimeWithZ
from ..app import DateTimeWithZ, ma
from ..auth.models import User


Expand Down
2 changes: 1 addition & 1 deletion server/mergin/sync/storages/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from result import Err, Ok, Result

from .storage import ProjectStorage, FileNotFound, InitializationError
from ... import db
from ...app import db
from ..utils import (
generate_checksum,
is_versioned_file,
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/sync/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .storages.disk import move_to_tmp
from .config import Configuration
from ..celery import celery
from .. import db
from ..app import db


@celery.task
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/sync/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .models import Project, ProjectAccess, AccessRequest, ProjectAccessDetail
from .permissions import projects_query, ProjectPermissions
from .public_api_controller import parse_project_access_update_request
from .. import db
from ..app import db
from ..auth.models import User
from ..config import Configuration
from .interfaces import AbstractWorkspace, WorkspaceHandler
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pygeodiff import GeoDiff
import pytest

from .. import db, create_app
from ..app import db, create_app
from ..sync.models import Project, ProjectVersion
from ..stats.app import register
from ..stats.models import MerginInfo
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from ..auth.models import User, UserProfile, LoginHistory
from ..auth.tasks import anonymize_removed_users
from .. import db
from ..app import db
from ..sync.models import Project
from . import (
test_workspace_id,
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from flask_mail import Mail
from unittest.mock import patch

from .. import db
from ..app import db
from ..config import Configuration
from ..sync.models import Project, AccessRequest, ProjectVersion
from ..celery import send_email_async
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/test_db_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)
from ..sync.files import UploadChanges
from ..auth.models import User
from .. import db
from ..app import db
from . import DEFAULT_USER
from .utils import add_user, create_project, create_workspace, cleanup

Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/test_file_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import shutil
from sqlalchemy.orm.attributes import flag_modified

from .. import db
from ..app import db
from ..auth.models import User
from ..sync.models import ProjectVersion, Project, GeodiffActionHistory
from . import test_project_dir, TMP_DIR
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ..sync.permissions import require_project, ProjectPermissions
from ..sync.models import ProjectRole
from ..auth.models import User
from .. import db
from ..app import db
from ..config import Configuration
from .utils import add_user, create_project, create_workspace

Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/test_private_project_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest
from flask import url_for

from .. import db
from ..app import db
from ..sync.models import AccessRequest, Project, ProjectRole, RequestStatus
from ..auth.models import User
from ..config import Configuration
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/test_project_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import tempfile

from sqlalchemy import desc
from .. import db
from ..app import db
from ..sync.models import (
Project,
Upload,
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/test_public_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial

from .. import db
from ..app import db
from mergin.sync.models import Project
from tests import test_project, test_workspace_id

Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from unittest.mock import patch
import requests

from .. import db
from ..app import db
from ..stats.tasks import send_statistics
from ..stats.models import MerginInfo
from .utils import Response
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sqlalchemy import desc
from unittest.mock import MagicMock

from .. import db
from ..app import db
from ..sync.utils import parse_gpkgb_header_size, gpkg_wkb_to_wkt, is_name_allowed
from ..auth.models import LoginHistory, User
from . import json_headers
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/test_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from sqlalchemy import null

from .. import db
from ..app import db
from ..config import Configuration
from ..sync.models import FileHistory, ProjectVersion, PushChangeType, ProjectFilePath
from ..sync.workspace import GlobalWorkspaceHandler
Expand Down
2 changes: 1 addition & 1 deletion server/mergin/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ..sync.models import Project, ProjectAccess, ProjectVersion, FileHistory
from ..sync.files import UploadChanges, ChangesSchema
from ..sync.workspace import GlobalWorkspace
from .. import db
from ..app import db
from . import json_headers, DEFAULT_USER, test_project, test_project_dir, TMP_DIR

CHUNK_SIZE = 1024
Expand Down

0 comments on commit 79e7a2b

Please sign in to comment.