def __init__(self): if ClientController._instance is not None: raise Exception("This class is a singleton!") else: ClientController._instance = self Controller.__init__(self, DatabaseContainer.get_instance()) self._db_loaded = False self._client_catalog = app.classes.catalogs.UserCatalog() self._catalog_controller = app.controllers.catalog_controller.CatalogController.get_instance( ) self._loan_catalog = app.classes.catalogs.LoanCatalog.get_instance( )
def __init__(self): if AdminController._instance is not None: raise Exception("This class is a singleton!") else: AdminController._instance = self Controller.__init__(self, DatabaseContainer.get_instance()) # Admin Controller should have an instance of catalog controller self._catalog_controller = CatalogController.get_instance() # Admin Controller contains a catalog of admin users self._admin_catalog = UserCatalog() # Admin Controller contains a catalog of loans self._loan_catalog = app.classes.catalogs.LoanCatalog.get_instance( ) self._db_loaded = False
def __init__(self): if CatalogController._instance is not None: raise Exception("This class is a singleton!") else: CatalogController._instance = self Controller.__init__(self, DatabaseContainer.get_instance()) self._inventory = { CatalogController.BOOK_TYPE: BookCatalog.get_instance(), CatalogController.MOVIE_TYPE: MovieCatalog.get_instance(), CatalogController.MAGAZINE_TYPE: MagazineCatalog.get_instance(), CatalogController.ALBUM_TYPE: AlbumCatalog.get_instance() } #CatalogController.LOAN_TYPE: LoanCatalog.get_instance()} self._constructors = { CatalogController.BOOK_TYPE: Book, CatalogController.MOVIE_TYPE: Movie, CatalogController.MAGAZINE_TYPE: Magazine, CatalogController.ALBUM_TYPE: Album } #CatalogController.LOAN_TYPE: Loan} self._db_loaded = False
def handler500(request, exception=None, template_name='templates/500.html'): """500 Error Page Controller""" controller = Controller() helpers = Helpers() logger = helpers.get_logger(__name__) if exception is not None: logger.error("Server Error: %(exception)s" % { "exception": exception }) template_name = 'templates/500.html' controller.autoload_options() controller.context_push({ "page_title": _("500 · %s") % controller.context_get("app_name", os.getenv("APP_NAME", "Silverback")) }) return render(request, template_name, controller.context_get(), status=500)
def handler404(request, exception=None, template_name='templates/404.html'): """404 Error Page Controller""" helpers = Helpers() controller = Controller() logger = helpers.get_logger(__name__) if exception is not None: logger.info("Route Not Found: %(exception)s" % {"exception": exception}) template_name = 'templates/404.html' controller.autoload_options() controller.context_push({ "page_title": _("404 · %s") % controller.context_get("app_name", os.getenv("APP_NAME", "Silverback")) }) return render(request, template_name, controller.context_get(), status=404)
def not_found(error=None): message = { 'status': 404, 'message': 'Route not found: ' + request.url } return Controller.buildResponse(404, message)
def index(): return Controller.buildResponse(200, {'message': 'API - IA Cidada!'})
def mwClaimsVerificationFailedCallback(e): return Controller.buildResponse(401, {"message": MSG_INVALID_CREDENTIALS, "description": e})
def myTokenInBlacklistCallback(e): return Controller.buildResponse(401, {"message": MSG_INVALID_CREDENTIALS, "description": e})
def myUnauthorizedCallback(e): return Controller.buildResponse(401, {"message": MSG_INVALID_CREDENTIALS, "description": e})
def myExpiredTokenCallback(): return Controller.buildResponse(401, {'message': MSG_TOKEN_EXPIRED})