@copyright: 2012 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Provides the Mongrel2 web server plugins settings. ''' from ally.container import ioc, support from ally.container.ioc import SetupError from __setup__.ally_core_http import server_type # -------------------------------------------------------------------- try: from ..cdm.local_cdm import use_linked_cdm except ImportError: pass # No CDM to setup. else: ioc.doc(use_linked_cdm, ''' !!!Attention, if the mongrel2 server is selected this option will always be "false" ''') @ioc.before(use_linked_cdm, auto=False) 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) # --------------------------------------------------------------------
"ipc:///tmp/send" - for using in processes that allow communication on the same computer processes ''' return 'ipc:///tmp/send' @ioc.config def recv_ident(): '''The receive ident to use in communication with Mongrel2, if not specified one will be created''' return '' @ioc.config def recv_spec(): '''The receive address to use in communication with Mongrel2, see more details at "address_request" configuration''' return 'ipc:///tmp/response' ioc.doc(server_type, ''' "mongrel2" - mongrel2 server integration, Attention!!! this is not a full server the content will be delivered by Mongrel2 server, so when you set this option please check the README.txt in the component sources ''') ioc.doc(server_host, ''' !!!Attention, if the mongrel2 server is selected this option is not used anymore, to change this option you need to alter the Mongrel2 configurations. ''') ioc.doc(server_port, ''' !!!Attention, if the mongrel2 server is selected this option is not used anymore, to change this option you need to alter the Mongrel2 configurations. ''') # -------------------------------------------------------------------- @ioc.entity def serverMongrel2RequestHandler(): from ally.http.server.server_mongrel2 import RequestHandler
from __setup__.ally_core_http.processor_error import statusToCode from __setup__.ally_core_http.server import server_pattern_resources, \ server_pattern_errors, server_provide_errors from ally.http.spec.codes import METHOD_NOT_AVAILABLE, PATH_NOT_FOUND, \ UNAUTHORIZED_ACCESS, FORBIDDEN_ACCESS, INVALID_AUTHORIZATION from ally.http.spec.server import HTTP_OPTIONS @ioc.before(statusToCode) def updateStatusToCodeForGateway(): statusToCode().update({ UNAUTHORIZED_ACCESS.status: UNAUTHORIZED_ACCESS, FORBIDDEN_ACCESS.status: FORBIDDEN_ACCESS, }) ioc.doc( server_pattern_errors, ''' !Attention if you change this configuration you need also to adjust the 'default_gateways' configuration ''') @ioc.before(default_gateways) def updateGatewayWithResourcesOptions(): default_gateways().extend([ { 'Pattern': server_pattern_resources(), 'Methods': [HTTP_OPTIONS], }, ]) @ioc.before(default_gateways) def updateGatewayWithResourcesErrors(): if server_provide_errors(): default_gateways().extend([
# -------------------------------------------------------------------- @ioc.config def server_name() -> str: '''The server name''' return 'localhost' @ioc.config def request_queue_size() -> int: '''The request queue size for the wsgi cherry py server''' return 500 ioc.doc( server_type, ''' "cherrypy" - multiple threaded server, but slow because of python GIL issue ''') # -------------------------------------------------------------------- @ioc.start def runServer(): if server_type() == 'cherrypy': from ally.core.http.server import server_cherrypy args = requestHandlerWSGI(), server_host(), server_port( ), request_queue_size(), server_name() Thread(target=server_cherrypy.run, args=args).start()
from ..ally_core_http import server_type, server_port, server_host from ..ally_core_http.server_basic import requestHandlerWSGI from ally.container import ioc from threading import Thread # -------------------------------------------------------------------- @ioc.config def server_name() -> str: '''The server name''' return 'localhost' @ioc.config def request_queue_size() -> int: '''The request queue size for the wsgi cherry py server''' return 500 ioc.doc(server_type, ''' "cherrypy" - multiple threaded server, but slow because of python GIL issue ''') # -------------------------------------------------------------------- @ioc.start def runServer(): if server_type() == 'cherrypy': from ally.core.http.server import server_cherrypy args = requestHandlerWSGI(), server_host(), server_port(), request_queue_size(), server_name() Thread(target=server_cherrypy.run, args=args).start()
''' Created on Nov 23, 2011 @package: support cdm @copyright: 2012 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Provides the Mongrel2 web server plugins patch for the cdm. ''' from __setup__.ally_http.server import server_type from ally.container import ioc, support from ..cdm.service import use_linked_cdm # -------------------------------------------------------------------- ioc.doc( use_linked_cdm, ''' !!!Attention, if the mongrel2 server is selected this option will always be "false" ''') @ioc.before(use_linked_cdm, auto=False) def use_linked_cdm_force(): if server_type() == 'mongrel2': support.force(use_linked_cdm, False)
@author: Gabriel Nistor Provides the Mongrel2 web server plugins patch for the cdm. ''' from ..ally_cdm.server import server_provide_content from ..ally_http.server import server_type from ally.container import ioc, support import logging # -------------------------------------------------------------------- log = logging.getLogger(__name__) # -------------------------------------------------------------------- try: from .. import ally_http_mongrel2_server # @UnusedImport except ImportError: log.info('No mongrel2 available thus skip the CDM patching') else: ioc.doc( server_provide_content, ''' !Attention, if the mongrel2 server is selected this option will always be "false" ''') @ioc.before(server_provide_content, auto=False) def server_provide_content_force(): if server_type() == 'mongrel2': support.force(server_provide_content, False)
@package: service CDM @copyright: 2012 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Provides the Mongrel2 web server plugins patch for the cdm. ''' from ..ally_cdm.server import server_provide_content from ..ally_http.server import server_type from ally.container import ioc, support import logging # -------------------------------------------------------------------- log = logging.getLogger(__name__) # -------------------------------------------------------------------- try: from .. import ally_http_mongrel2_server # @UnusedImport except ImportError: log.info('No mongrel2 available thus skip the CDM patching') else: ioc.doc(server_provide_content, ''' !Attention, if the mongrel2 server is selected this option will always be "false" ''') @ioc.before(server_provide_content, auto=False) def server_provide_content_force(): if server_type() == 'mongrel2': support.force(server_provide_content, False)
from ally.support.sqlalchemy.session import bindSession from sql_alchemy import database_config from sql_alchemy.database_config import alchemySessionCreator, alchemyEngine from superdesk.meta.metadata_superdesk import meta # -------------------------------------------------------------------- support.include(database_config) # -------------------------------------------------------------------- @ioc.replace(database_url) def database_url(): '''This database URL is used for the Superdesk tables''' return 'sqlite:///workspace/shared/superdesk.db' # We make the security use the same engine. @ioc.replace(getattr(db_security, 'alchemyEngine')) # Use of getattr is just to get rid of the IDE error def alchemyEngineSuperdesk(): return alchemyEngine() @ioc.before(db_security.updateMetasForSecurity) def updateMetasForSuperdesk(): db_security.metas().append(meta) # The superdesk meta needs to be created before the security meta because of RacUser ioc.doc(db_security.database_url, 'This is absolute with superdesk plugin') # -------------------------------------------------------------------- def bindSuperdeskSession(proxy): bindSession(proxy, alchemySessionCreator()) def bindSuperdeskValidations(proxy): bindValidations(proxy, mappingsOf(meta))
PATH_NOT_FOUND, UNAUTHORIZED_ACCESS, FORBIDDEN_ACCESS, INVALID_AUTHORIZATION, ) from ally.http.spec.server import HTTP_OPTIONS @ioc.before(statusToCode) def updateStatusToCodeForGateway(): statusToCode().update( {UNAUTHORIZED_ACCESS.status: UNAUTHORIZED_ACCESS, FORBIDDEN_ACCESS.status: FORBIDDEN_ACCESS} ) ioc.doc( server_pattern_errors, """ !Attention if you change this configuration you need also to adjust the 'default_gateways' configuration """, ) @ioc.before(default_gateways) def updateGatewayWithResourcesOptions(): default_gateways().extend([{"Pattern": server_pattern_resources(), "Methods": [HTTP_OPTIONS]}]) @ioc.before(default_gateways) def updateGatewayWithResourcesErrors(): if server_provide_errors(): default_gateways().extend( [ # If path is not found then we try to dispatch a unauthorized access if the path is not # found in REST the default error will have priority over the unauthorized access {