예제 #1
0
    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(
            )
예제 #2
0
    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
예제 #3
0
 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
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
def not_found(error=None):
    message = {
        'status': 404,
        'message': 'Route not found: ' + request.url
    }
    return Controller.buildResponse(404, message)
예제 #7
0
def index():
    return Controller.buildResponse(200, {'message': 'API - IA Cidada!'})
예제 #8
0
def mwClaimsVerificationFailedCallback(e):
    return Controller.buildResponse(401, {"message": MSG_INVALID_CREDENTIALS, "description": e})
예제 #9
0
def myTokenInBlacklistCallback(e):
    return Controller.buildResponse(401, {"message": MSG_INVALID_CREDENTIALS, "description": e})
예제 #10
0
def myUnauthorizedCallback(e):
    return Controller.buildResponse(401, {"message": MSG_INVALID_CREDENTIALS, "description": e})
예제 #11
0
def myExpiredTokenCallback():    
    return Controller.buildResponse(401, {'message': MSG_TOKEN_EXPIRED})