Exemplo n.º 1
0
 def __init__(self):
     # Instance variables
     self._version = uvicore.__version__
     self._debug = False
     self._perfs = []
     self._http = None
     #self._config = None  # None until config provider registered
     self._providers = OrderedDict()
     self._registered = False
     self._booted = False
     self._is_console = False
     self._is_http = False
     self._packages = OrderedDict()
     self._path = None
     self._name = None
     self._main = None
Exemplo n.º 2
0
    def _get_all_ioc_models(self) -> OrderedDict:
        """Get all models in tablename sorted order from Ioc bindings"""
        models = OrderedDict()
        unsorted_models = {}
        model_bindings = uvicore.ioc.binding(type='model', include_overrides=False)

        all_model_keys = set(model_bindings.keys())
        model_keys = []

        # If include, only include these models (wildcards accepted)
        if self.include:
            for include in self.include:
                model_keys.extend(fnmatch.filter(all_model_keys, include))

            # Ensure unique List in case of double include entries matching double
            model_keys = list(set(model_keys))
        else:
            # No includes, use all models
            model_keys = all_model_keys

        # If exclude, remove them from the list (wildcards accepted)
        if self.exclude:
            for exclude in self.exclude:
                model_keys = [x for x in model_keys if x not in fnmatch.filter(model_keys, exclude)]

        # Now we have our exact models as list of python module paths from the IOC
        # Now we get actual IOC bindings except our Dict Key is the TABLENAME, not module path
        for model in model_keys:
            tablename = model_bindings[model].object.tablename
            if tablename not in models:
                unsorted_models[tablename] = model_bindings[model]

        # Now we can sort our unsorted_model keys (which are tablenames)
        tablenames = sorted(unsorted_models.keys())

        # Add all sorted models to our final models OrderedDict
        for tablename in tablenames:
            models[tablename] = unsorted_models[tablename]

        return models
Exemplo n.º 3
0
    # minimal and only depends on configuration, logging and console itself.
    # You must add other core services built into uvicore only if your package
    # requires them.  Services like uvicore.database, uvicore.orm, uvicore.auth
    # uvicore.http, etc...
    # --------------------------------------------------------------------------
    'dependencies': OrderedDict({
        'uvicore.foundation': {
            'provider': 'uvicore.foundation.services.Foundation',
        },
        'uvicore.redis': {
            'provider': 'uvicore.redis.services.Redis',
        },
        'uvicore.database': {
            'provider': 'uvicore.database.services.Database',
        },
        'uvicore.orm': {
            'provider': 'uvicore.orm.services.Orm',
        },
        'uvicore.auth': {
            'provider': 'uvicore.auth.services.Auth',
        },
        'uvicore.http': {
            'provider': 'uvicore.http.services.Http',
        },
        'uvicore.http_client': {
            'provider': 'uvicore.http_client.services.HttpClient',
        },
    }),

}
Exemplo n.º 4
0
        'middleware': OrderedDict({
            # Only allow this site to be hosted from these domains
            'TrustedHost': {
                'module': 'uvicore.http.middleware.TrustedHost',
                'options': {
                    'allowed_hosts': ['127.0.0.1', 'localhost'],
                    'www_redirect': True,
                }
            },

            # Detect one or more authentication mechanisms and load valid or anonymous user into request.user
            # 'Authentication': {
            #     # All options are configured in the 'auth' section of this app config
            #     'module': 'uvicore.http.middleware.Authentication',
            #     'options': {
            #         'route_type': 'web',  # web or api only
            #     }
            # },

            # If you have a loadbalancer with SSL termination in front of your web
            # app, don't use this redirection to enforce HTTPS as it is always HTTP internally.
            # 'HTTPSRedirect': {
            #     'module': 'uvicore.http.middleware.HTTPSRedirect',
            # },
            # Not needed if your loadbalancer or web server handles gzip itself.
            # 'GZip': {
            #     'module': 'uvicore.http.middleware.Gzip',
            #     'options': {
            #         # Do not GZip responses that are smaller than this minimum size in bytes. Defaults to 500
            #         'minimum_size': 500
            #     }
            # },
        }),
Exemplo n.º 5
0
    OrderedDict({
        # Foundation is the core of uvicore and is required as the first dependency.
        # Foundation itself relys on configuration, logging, console, cache and more.
        'uvicore.foundation': {
            'provider': 'uvicore.foundation.services.Foundation',
        },

        # Redis provides redis access and redis caching if enabled in your app config
        # 'uvicore.redis': {
        #     'provider': 'uvicore.redis.services.Redis',
        # },

        # Database is required for database queries and the ORM.  Disable if your project
        # does not require database or models
        'uvicore.database': {
            'provider': 'uvicore.database.services.Database',
        },

        # ORM provides an object relationional mapper between your databse tables
        # and your ORM models.  Disable if your project does not require Models.
        # Even without the ORM, you can still use the database with the db query builder.
        'uvicore.orm': {
            'provider': 'uvicore.orm.services.Orm',
        },

        # Auth provides all of the auth middleware, user providers, authenticators and guards
        'uvicore.auth': {
            'provider': 'uvicore.auth.services.Auth',
        },

        # HTTP provides API and WEB endpoints, assets, templates.  A full webserver.
        'uvicore.http': {
            'provider': 'uvicore.http.services.Http',
        },

        # HTTP async client based on aiohttp.  Enable this package if you need
        # to query other HTTP endpoints in your package.
        # 'uvicore.http_client': {
        #     'provider': 'uvicore.http_client.services.HttpClient',
        # },
    }),
Exemplo n.º 6
0
    # --------------------------------------------------------------------------
    # Package Dependencies (Service Providers)
    #
    # Define all the packages that this package depends on.  At a minimum, only
    # the uvicore.foundation package is required.  The foundation is very
    # minimal and only depends on configuratino, logging and console itself.
    # You must add other core services built into uvicore only if your package
    # requires them.  Services like uvicore.database, uvicore.orm, uvicore.auth
    # uvicore.http, etc...
    # --------------------------------------------------------------------------
    'dependencies':
    OrderedDict({
        'uvicore.foundation': {
            'provider': 'uvicore.foundation.services.Foundation',
        },
        # 'uvicore.database': {
        #     'provider': 'uvicore.database.services.Database',
        # },
        # 'uvicore.orm': {
        #     'provider': 'uvicore.orm.services.Orm',
        # },
        # 'uvicore.auth': {
        #     'provider': 'uvicore.auth.services.Auth',
        # },
        # 'uvicore.http': {
        #     'provider': 'uvicore.http.services.Http',
        # },
    }),
}
Exemplo n.º 7
0
    # You must add other core services built into uvicore only if your package
    # requires them.  Services like uvicore.database, uvicore.orm, uvicore.auth
    # uvicore.http, etc...
    # --------------------------------------------------------------------------
    'dependencies': OrderedDict({
        # Wiki uses database, orm, auth, http
        'uvicore.foundation': {
            'provider': 'uvicore.foundation.services.Foundation',
        },
        'uvicore.redis': {
            'provider': 'uvicore.redis.services.Redis',
        },
        'uvicore.database': {
            'provider': 'uvicore.database.services.Database',
        },
        'uvicore.orm': {
            'provider': 'uvicore.orm.services.Orm',
        },
        'uvicore.auth': {
            'provider': 'uvicore.auth.services.Auth',
        },
        'uvicore.http': {
            'provider': 'uvicore.http.services.Http',
        },
        'mreschke.fusionauth': {
            'provider': 'mreschke.fusionauth.services.fusionauth.Fusionauth',
        },
    }),

}
Exemplo n.º 8
0
    # requires them.  Services like uvicore.database, uvicore.orm, uvicore.http
    # uvicore.auth...
    # --------------------------------------------------------------------------
    'dependencies': OrderedDict({
        # Careful to only define REQUIRED services for a minimal Uvicore.  Things
        # like auth, db, http, etc... are optional and specified in a packages
        # dependencies if needed.

        # Configuration is used right away in provider register()
        'uvicore.configuration': {
            'provider': 'uvicore.configuration.services.Configuration',
        },

        # I want logging quick as it may be used in providers register() and boot()
        'uvicore.logging': {
            'provider': 'uvicore.logging.services.Logging',
        },

        # Console is required for every uvicore app
        'uvicore.console': {
            'provider': 'uvicore.console.services.Console',
        },

        # Cache is required for every uvicore app
        'uvicore.cache': {
            'provider': 'uvicore.cache.services.Cache',
        },
    }),

}