Exemplo n.º 1
0
 def use_linked_cdm_force():
     try: import application
     except ImportError: raise SetupError('Cannot access the application module')
     ioc.activate(application.assembly)
     force = server_type() == 'mongrel2'
     ioc.deactivate()
     if force: support.force(use_linked_cdm, False)
Exemplo n.º 2
0
def registerAuthentication(support):
    assert isinstance(support, IAuthenticationSupport), 'Invalid support %s' % support
    try: import application
    except ImportError: raise SetupError('Cannot access the application module')
    activate(application.assembly)
    authenticators().append(support)
    deactivate()
Exemplo n.º 3
0
def dump():
    assert isinstance(application.options, OptionsCore), 'Invalid application options %s' % application.options
    if not application.options.writeConfigurations: return
    if not __debug__:
        print('Cannot dump configuration file if python is run with "-O" or "-OO" option', file=sys.stderr)
        sys.exit(1)
    try:
        ioc.activate(application.assembly)
        try: 
            loadPlugins()
            configFile = configurations_file_path()
        finally: ioc.deactivate()
        
        if os.path.isfile(configFile):
            with open(configFile, 'r') as f: config = load(f)
        else: config = {}
        
        assembly = ioc.open(aop.modulesIn('__plugin__.**'), config=config)
        assert isinstance(assembly, Assembly), 'Invalid assembly %s' % assembly
        try:
            if os.path.isfile(configFile): os.rename(configFile, configFile + '.bak')
            for config in assembly.configurations: assembly.processForName(config)
            # Forcing the processing of all configurations
            with open(configFile, 'w') as f: save(assembly.trimmedConfigurations(), f)
            print('Created "%s" configuration file' % configFile)
        finally: ioc.deactivate()
    
    except SystemExit: raise
    except:
        print('-' * 150, file=sys.stderr)
        print('A problem occurred while dumping configurations', file=sys.stderr)
        traceback.print_exc(file=sys.stderr)
        print('-' * 150, file=sys.stderr)
Exemplo n.º 4
0
def compileProcessings(assembly):
    '''
    Compiles the path assemblies to path processings.
    '''
    assert isinstance(assembly, ioc_setup.Assembly)

    ioc.activate(assembly)
    pathAssemblies, pathProcessing = assembly.processForPartialName(
        'pathAssemblies'), []
    ioc.deactivate()

    for pattern, assembly in pathAssemblies:
        assert isinstance(pattern, str), 'Invalid pattern %s' % pattern
        assert isinstance(assembly, Assembly), 'Invalid assembly %s' % assembly

        processing, report = assembly.create(ONLY_AVAILABLE,
                                             CREATE_REPORT,
                                             request=RequestHTTP,
                                             requestCnt=RequestContentHTTP,
                                             response=ResponseHTTP,
                                             responseCnt=ResponseContentHTTP)

        print('Assembly report for pattern \'%s\':\n%s' % (pattern, report))
        pathProcessing.append((re.compile(pattern), processing))

    return pathProcessing
Exemplo n.º 5
0
def requestService() -> IRequestService:
    try: import application
    except ImportError: raise SetupError('Cannot access the application module')
    ioc.activate(application.assembly)
    value = requestService()
    ioc.deactivate()
    return value
Exemplo n.º 6
0
def publish_development():
    '''
    If true the development services will be published.
    '''
    try: import application
    except ImportError: raise SetupError('Cannot access the application module')
    ioc.activate(application.assembly)
    value = publish_development()
    ioc.deactivate()
    return value
Exemplo n.º 7
0
def compileProcessings(assembly):
    '''
    Compiles the path assemblies to path processings.
    '''
    assert isinstance(assembly, ioc_setup.Assembly)
    
    ioc.activate(assembly)
    pathAssemblies, pathProcessing = assembly.processForPartialName('pathAssemblies'), []
    ioc.deactivate()
    
    for pattern, assembly in pathAssemblies:
        assert isinstance(pattern, str), 'Invalid pattern %s' % pattern
        assert isinstance(assembly, Assembly), 'Invalid assembly %s' % assembly

        processing, report = assembly.create(ONLY_AVAILABLE, CREATE_REPORT,
                                             request=RequestHTTP, requestCnt=RequestContentHTTP,
                                             response=ResponseHTTP, responseCnt=ResponseContentHTTP)

        print('Assembly report for pattern \'%s\':\n%s' % (pattern, report))
        pathProcessing.append((re.compile(pattern), processing))
        
    return pathProcessing
Exemplo n.º 8
0
@copyright: 2012 Sourcefabric o.p.s.
@license: http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Configuration to add multiprocessing abilities to the database.
'''

from __setup__.ally_core_http import server_type
from ally.container import ioc
import ally_deploy_application
import logging

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

log = logging.getLogger(__name__)

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

ioc.activate(ally_deploy_application.assembly)
if server_type() == 'production':
    try:
        from sql_alchemy.multiprocess_config import enableMultiProcessPool
    except ImportError:
        # Probably there is no sql alchemy available.
        log.warning(
            'Cannot enable multiple processors support for database connection pools',
            exc_info=True)
    else:
        enableMultiProcessPool()
ioc.deactivate()
Exemplo n.º 9
0
Created on Oct 18, 2012

@package: ally core http
@copyright: 2012 Sourcefabric o.p.s.
@license: http://www.gnu.org/licenses/gpl-3.0.txt
@author: Gabriel Nistor

Configuration to add multiprocessing abilities to the database.
'''

from __setup__.ally_core_http import server_type
from ally.container import ioc
import ally_deploy_application
import logging

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

log = logging.getLogger(__name__)

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

ioc.activate(ally_deploy_application.assembly)
if server_type() == 'production':
    try:
        from sql_alchemy.multiprocess_config import enableMultiProcessPool
    except ImportError:
        # Probably there is no sql alchemy available.
        log.warning('Cannot enable multiple processors support for database connection pools', exc_info=True)
    else: enableMultiProcessPool()
ioc.deactivate()
Exemplo n.º 10
0
def registerAuthentication(support):
    assert isinstance(support, IAuthenticationSupport), 'Invalid support %s' % support

    activate(ally_deploy_application.assembly)
    authenticators().append(support)
    deactivate()