server/general: move errors to top level NS
This commit is contained in:
parent
06cf8c79d4
commit
769ef8f141
|
@ -1,7 +1,7 @@
|
||||||
''' Users public API. '''
|
''' Users public API. '''
|
||||||
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from szurubooru.services.errors import IntegrityError, ValidationError
|
from szurubooru.errors import IntegrityError, ValidationError
|
||||||
from szurubooru.api.base_api import BaseApi
|
from szurubooru.api.base_api import BaseApi
|
||||||
|
|
||||||
def _serialize_user(authenticated_user, user):
|
def _serialize_user(authenticated_user, user):
|
||||||
|
|
|
@ -9,6 +9,7 @@ import szurubooru.config
|
||||||
import szurubooru.middleware
|
import szurubooru.middleware
|
||||||
import szurubooru.services
|
import szurubooru.services
|
||||||
import szurubooru.util
|
import szurubooru.util
|
||||||
|
from szurubooru.errors import *
|
||||||
|
|
||||||
class _CustomRequest(falcon.Request):
|
class _CustomRequest(falcon.Request):
|
||||||
context_type = szurubooru.util.dotdict
|
context_type = szurubooru.util.dotdict
|
||||||
|
@ -56,9 +57,9 @@ def create_app():
|
||||||
szurubooru.middleware.Authenticator(auth_service, user_service),
|
szurubooru.middleware.Authenticator(auth_service, user_service),
|
||||||
])
|
])
|
||||||
|
|
||||||
app.add_error_handler(szurubooru.services.AuthError, _on_auth_error)
|
app.add_error_handler(szurubooru.errors.AuthError, _on_auth_error)
|
||||||
app.add_error_handler(szurubooru.services.IntegrityError, _on_integrity_error)
|
app.add_error_handler(szurubooru.errors.IntegrityError, _on_integrity_error)
|
||||||
app.add_error_handler(szurubooru.services.ValidationError, _on_validation_error)
|
app.add_error_handler(szurubooru.errors.ValidationError, _on_validation_error)
|
||||||
|
|
||||||
app.add_route('/users/', user_list)
|
app.add_route('/users/', user_list)
|
||||||
app.add_route('/user/{user_name}', user)
|
app.add_route('/user/{user_name}', user)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import base64
|
import base64
|
||||||
import falcon
|
import falcon
|
||||||
from szurubooru.model.user import User
|
from szurubooru.model.user import User
|
||||||
from szurubooru.services.errors import AuthError
|
from szurubooru.errors import AuthError
|
||||||
|
|
||||||
class Authenticator(object):
|
class Authenticator(object):
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -6,5 +6,3 @@ All the business logic goes here.
|
||||||
from szurubooru.services.auth_service import AuthService
|
from szurubooru.services.auth_service import AuthService
|
||||||
from szurubooru.services.user_service import UserService
|
from szurubooru.services.user_service import UserService
|
||||||
from szurubooru.services.password_service import PasswordService
|
from szurubooru.services.password_service import PasswordService
|
||||||
from szurubooru.services.errors import (
|
|
||||||
AuthError, IntegrityError, ValidationError)
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
''' Exports AuthService. '''
|
''' Exports AuthService. '''
|
||||||
|
|
||||||
from szurubooru.services.errors import AuthError
|
from szurubooru.errors import AuthError
|
||||||
|
|
||||||
class AuthService(object):
|
class AuthService(object):
|
||||||
''' Services related to user authentication '''
|
''' Services related to user authentication '''
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from szurubooru.services.errors import ValidationError
|
from szurubooru.errors import ValidationError
|
||||||
from szurubooru.model.user import User
|
from szurubooru.model.user import User
|
||||||
|
|
||||||
class UserService(object):
|
class UserService(object):
|
||||||
|
|
Loading…
Reference in New Issue