Beispiel #1
0
from gateway.core.impl.processor.default_gateway import RegisterDefaultGateways

# --------------------------------------------------------------------

registerDefaultGateways = support.notCreated  # Just to avoid errors

# --------------------------------------------------------------------

SERVICES = 'gateway.api.**.I*Service'

support.createEntitySetup('gateway.impl.**.*', RegisterDefaultGateways)
support.listenToEntities(SERVICES, listeners=registerService)
support.loadAllEntities(SERVICES)

# --------------------------------------------------------------------

default_gateways = ioc.entityOf(nameInEntity(RegisterDefaultGateways, 'default_gateways'))

# --------------------------------------------------------------------

@ioc.entity
def assemblyAnonymousGateways() -> Assembly:
    ''' The assembly used for generating anonymous gateways'''
    return Assembly('Anonymous gateways')

# --------------------------------------------------------------------

@ioc.before(assemblyAnonymousGateways)
def updateAssemblyAnonymousGateways():
    assemblyAnonymousGateways().add(registerDefaultGateways())
from ..gui_core.service import updateAssemblyConfiguration
from ..hr import service
from hr.user.api.user import IUserService


# --------------------------------------------------------------------
@ioc.before(configurationStreams)
def updateConfigurationStreamsForDistribution():
    content = pkgutil.get_data('__plugin__.distribution_ally_user_management', 'security_configuration.xml')
    configurationStreams().append(('file://.../security_configuration.xml', lambda: BytesIO(content)))

@ioc.after(updateAssemblyConfiguration)
def updateAssemblyConfigurationForTest():
    assemblyGUIConfiguration().remove(uriRepositoryCaching())

@ioc.after(ioc.entityOf('userService', module=service))
def userServiceUpdate():
    class AutoRolesProxy(IProxyHandler):
        ''' Automatically assign roles to new created users.'''
         
        def __init__(self, userRbacService):
            self.userRbacService = userRbacService
         
        def handle(self, execution):
            userId = execution.invoke()
            self.userRbacService.addRole(userId, 'Admin')
            return userId
             
    userService = support.entityFor(IUserService)
    handler = AutoRolesProxy(support.entityFor(IUserRbacService))
    handler = ProxyFilter(handler, 'insert')