Beispiel #1
0
def serializer_loads(d):

    import inject
    inject.configure_once()

    for k, v in d.items():
        """
            se matchea en el formato isoformat
            2016-03-19T16:56:26.767543
        """
        if isinstance(v, str) and re.search("\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d+", v):
            try:
                d[k] = dateutil.parser.parse(v)
            except:
                pass

    instance = None
    if '__json_class__' in d.keys():
        module = importlib.import_module(d['__json_module__'])
        clazz = getattr(module, d['__json_class__'])
        instance = clazz()
        instance.__dict__ = d

    else:
        instance = d

    return instance
Beispiel #2
0
def bootstrap(config):
    dal = SqlAlchemy(config['postgres_conn_string'])
    dal.configure_mappings()

    # configure bindings
    unit_of_work_manager = dal.unit_of_work_manager()
    inject.configure_once(
        lambda binder: binder.bind('UnitOfWorkManager', unit_of_work_manager
                                   ).bind('Shortifier', UUIDShortifier()))

    logging.config.dictConfig(config['logging'])
Beispiel #3
0
def bootstrap(config):
    dal = SqlAlchemy(config['postgres_conn_string'])
    dal.configure_mappings()

    # configure bindings
    unit_of_work_manager = dal.unit_of_work_manager()
    inject.configure_once(
        lambda binder: binder.bind(
            'UnitOfWorkManager', unit_of_work_manager
        ).bind(
            'Shortifier', UUIDShortifier()
        )
    )

    logging.config.dictConfig(config['logging'])
Beispiel #4
0
def configure():
    """Configuration entrypoint."""
    inject.configure_once(inject_config)
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import inject

from app import config
from app.StateConfig import StateConfig
from app.XmlConfigParser import XMLConifgBot


def diConfig(binder):
    binder.bind('statesConfig',
                StateConfig(XMLConifgBot(config.xml_config_path).getContent()))


inject.configure_once(diConfig)
Beispiel #6
0
    }

    referencia: crossbar.router.auth.pending.PendingAuth._assign_principal

"""

import datetime
import dateutil.tz

from twisted.internet.defer import inlineCallbacks
from autobahn.twisted.wamp import ApplicationSession
from autobahn.wamp.exception import ApplicationError
import uuid
import autobahn
import inject
inject.configure_once()

import copy

from model.login.login import Login
import wamp


class AnonymousAuth(wamp.SystemComponentSession):

    @autobahn.wamp.register('authenticate.anonymous')
    def authenticate(self, realm, authid, details):
        principal = {
            'realm': 'public',
            'role': 'anonymous',
            'extra': {
Beispiel #7
0
 def test_configure_once__should_return_existing_injector_when_present(self):
     injector0 = inject.configure()
     injector1 = inject.configure_once()
     assert injector0 is injector1
Beispiel #8
0
 def test_configure_once__should_create_injector(self):
     injector = inject.configure_once()
     assert inject.get_injector() is injector
 def __init__(self, flag):
     self.flag = flag
     inject.configure_once(
         self.config_wrapper(self.get_dependencies_binding(), ))
Beispiel #10
0
 def ready(self):
     inject.configure_once(self.configure)
Beispiel #11
0
def init():
    inject.configure_once(_config)
Beispiel #12
0
"""myproject URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include

import inject
from shared.provider import shared_provider_config
inject.configure_once(shared_provider_config)

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include('myapp.urls')),
    path('', include('clients.urls'))
]
Beispiel #13
0
def configure_once():  # pragma: no cover
    inject.configure_once(config)
Beispiel #14
0
 def setUp(self) -> None:
     super().setUp()
     inject.configure_once(config_inject)
     self.client = APIClient()
Beispiel #15
0
 def test_configure_once__should_create_injector(self):
     injector = inject.configure_once()
     assert inject.get_injector() is injector
Beispiel #16
0
"""
WSGI config for TreloSinc project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""

import os

import inject
from django.core.wsgi import get_wsgi_application

from TreloSinc.inject import config_inject

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TreloSinc.settings')

application = get_wsgi_application()

# Configure dependency injection

inject.configure_once(config_inject)
Beispiel #17
0
 def test_configure_once__should_return_existing_injector_when_present(
         self):
     injector0 = inject.configure()
     injector1 = inject.configure_once()
     assert injector0 is injector1
Beispiel #18
0
 def setUp(self):
     inject.configure_once(inject_config)
     self.target = HubController()