def enableMultiProcessPool(): ''' Wraps all the engines in the current assembly with a pool that allows for working on multiple processes. ''' def present(engine): ''' Used for listening to all sql alchemy engines that are created in order to wrap the engine pool with a pool that can handle multiple processors. ''' if not isinstance(engine.pool, SingletonProcessWrapper): engine.pool = SingletonProcessWrapper(engine.pool) support.listenToEntities(Engine, listeners=present, module=callerLocals(), all=True)
from cdm.support import ExtendPathCDM from internationalization.api.po_file import IPOFileService from internationalization.impl.po_file import POFileService from internationalization.scanner import Scanner from internationalization.api.json_locale import IJSONLocaleFileService from internationalization.impl.json_locale import JSONFileService # -------------------------------------------------------------------- SERVICES = 'internationalization.api.**.I*Service' support.createEntitySetup('internationalization.impl.**.*') support.createEntitySetup('internationalization.*.impl.**.*') support.wireEntities(Scanner) support.bindToEntities('internationalization.impl.**.*Alchemy', binders=bindInternationalizationSession) support.listenToEntities(SERVICES, listeners=addService(bindInternationalizationValidations), beforeBinding=False) support.loadAllEntities(SERVICES) # -------------------------------------------------------------------- @ioc.config def scan_localized_messages(): '''Flag indicating that the application should be scanned for localized messages''' return False # -------------------------------------------------------------------- @ioc.entity def scanner(): return Scanner() @ioc.entity
Contains the services for superdesk. ''' from ..plugin.registry import addService from .db_superdesk import bindSuperdeskSession, bindSuperdeskValidations from ally.container import support, bind, ioc from itertools import chain # -------------------------------------------------------------------- SERVICES = 'superdesk.*.api.**.I*Service' @ioc.entity def binders(): return [bindSuperdeskSession] @ioc.entity def bindersService(): return list(chain((bindSuperdeskValidations, ), binders())) bind.bindToEntities('superdesk.*.impl.**.*Alchemy', binders=binders) support.createEntitySetup('superdesk.*.impl.**.*') support.listenToEntities(SERVICES, listeners=addService(bindersService)) support.loadAllEntities(SERVICES) # --------------------------------------------------------------------
''' Created on Jan 9, 2012 @@package: administration @copyright: 2012 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Contains the services for the administration support. ''' from ..plugin.registry import registerService from ally.container import support # -------------------------------------------------------------------- SERVICES = 'admin.**.api.**.I*Service' support.createEntitySetup('admin.**.impl.**.*') support.listenToEntities(SERVICES, listeners=registerService, beforeBinding=False) support.loadAllEntities(SERVICES)
from ..acl import gui from ..gui_action import defaults from ..gui_action.service import addAction from ..gui_core.gui_core import publishedURI from acl.right_action import RightAction from admin.introspection.api.component import IComponentService from admin.introspection.api.plugin import IPluginService from admin.introspection.api.request import IRequestService from ally.container import ioc, support from ally.internationalization import NC_ from gui.action.api.action import Action # -------------------------------------------------------------------- support.listenToEntities(Action, listeners=addAction) support.loadAllEntities(Action) # -------------------------------------------------------------------- @ioc.entity def menuAction() -> Action: return Action('request', NC_('menu', 'Request'), Parent=defaults.menuAction(), NavBar='/api-requests', Script=publishedURI('superdesk/request/scripts/js/menu.js')) @ioc.entity
from ally.container import ioc, support from cdm.spec import ICDM from cdm.support import ExtendPathCDM from superdesk.media_archive.api.meta_data import IMetaDataService from superdesk.media_archive.core.impl.thumbnail_referencer import \ ThumbnailReferencer from superdesk.media_archive.core.spec import IThumbnailReferencer from superdesk.media_archive.impl.meta_data import IMetaDataHandler, \ MetaDataServiceAlchemy # -------------------------------------------------------------------- def addMetaDataHandler(handler): if not isinstance(handler, IMetaDataService): metaDataHandlers().append(handler) support.listenToEntities(IMetaDataHandler, listeners=addMetaDataHandler, setupModule=service, beforeBinding=False) # -------------------------------------------------------------------- @ioc.entity def cdmArchive() -> ICDM: ''' The content delivery manager (CDM) for the media archive. ''' return ExtendPathCDM(contentDeliveryManager(), 'media_archive/%s') @ioc.entity def cdmThumbnail() -> ICDM: ''' The content delivery manager (CDM) for the thumbnails media archive. '''
from sched import scheduler from threading import Thread import time # -------------------------------------------------------------------- SERVICES = 'livedesk.api.**.I*Service' @ioc.entity def binders(): return [bindSuperdeskSession] @ioc.entity def bindersService(): return list(chain((bindSuperdeskValidations,), binders())) bind.bindToEntities('livedesk.impl.**.*Alchemy', IBlogCollaboratorGroupCleanupService, binders=binders) support.createEntitySetup('livedesk.impl.**.*') support.listenToEntities(SERVICES, listeners=addService(bindersService)) support.loadAllEntities(SERVICES) # -------------------------------------------------------------------- @ioc.entity def blogThemeCDM() -> ICDM: return contentDeliveryManager() # -------------------------------------------------------------------- @ioc.entity def versionCDM() -> ICDM: return contentDeliveryManager() # -------------------------------------------------------------------- @ioc.entity
''' Created on Jan 9, 2012 @package: introspection @copyright: 2011 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Contains the services for the introspection. ''' from ..plugin.registry import addService from ally.container import support # -------------------------------------------------------------------- API, IMPL = 'gui.*.api.**.I*Service', 'gui.*.impl.**.*' support.createEntitySetup(API, IMPL) support.listenToEntities(IMPL, listeners=addService()) support.loadAllEntities(API) # --------------------------------------------------------------------
from cdm.support import ExtendPathCDM from internationalization.api.po_file import IPOFileService from internationalization.core.impl.po_file_manager import POFileManager from internationalization.core.spec import IPOFileManager from internationalization.impl.po_file import POFileService from internationalization.scanner import Scanner from internationalization.api.json_locale import IJSONLocaleFileService from internationalization.impl.json_locale import JSONFileService # -------------------------------------------------------------------- API, IMPL = 'internationalization.api.**.I*Service', 'internationalization.impl.**.*' support.createEntitySetup(API, IMPL) support.bindToEntities(IMPL, binders=bindInternationalizationSession) support.listenToEntities(IMPL, listeners=addService(bindInternationalizationSession, bindInternationalizationValidations)) support.wireEntities(Scanner, POFileManager, POFileService) support.loadAllEntities(API) # -------------------------------------------------------------------- @ioc.config def scan_localized_messages(): '''Flag indicating that the application should be scanned for localized messages''' return False # -------------------------------------------------------------------- @ioc.entity def scanner(): return Scanner()
''' Created on Jan 9, 2012 @package: superdesk @copyright: 2012 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Contains the services for superdesk. ''' from ..ally_authentication_http.authentication import registerAuthentication from ..plugin.registry import addService from .db_superdesk import bindSuperdeskSession, bindSuperdeskValidations from ally.api.operator.authentication.service import IAuthenticationSupport from ally.container import support # -------------------------------------------------------------------- API, IMPL = 'superdesk.**.api.**.I*Service', 'superdesk.**.impl.**.*' support.createEntitySetup(API, IMPL) support.bindToEntities(IMPL, binders=bindSuperdeskSession) support.listenToEntities(IMPL, listeners=addService(bindSuperdeskSession, bindSuperdeskValidations)) support.listenToEntities(IAuthenticationSupport, listeners=registerAuthentication, beforeBinding=False) support.loadAllEntities(API) # --------------------------------------------------------------------
Contains the services for superdesk. ''' from ..plugin.registry import addService from .db_superdesk import bindSuperdeskSession, bindSuperdeskValidations from ally.api.operator.authentication.service import IAuthenticationSupport from ally.container import support # -------------------------------------------------------------------- SERVICES = 'superdesk.*.api.**.I*Service' support.createEntitySetup('superdesk.*.impl.**.*') support.bindToEntities('superdesk.*.impl.**.*Alchemy', binders=bindSuperdeskSession) support.listenToEntities(SERVICES, listeners=addService(bindSuperdeskSession, bindSuperdeskValidations)) try: from ..ally_authentication_http.authentication import registerAuthentication except ImportError: pass else: support.listenToEntities(IAuthenticationSupport, listeners=registerAuthentication, beforeBinding=False) support.loadAllEntities(SERVICES) # --------------------------------------------------------------------
log = logging.getLogger(__name__) # -------------------------------------------------------------------- try: from __setup__ import ally_core # @UnusedImport except ImportError: log.info( 'No ally core component available, cannot register the introspection') else: from __setup__.ally_core.resources import injectorAssembly from admin.introspection.core.impl.processor.index_model import IndexModelHandler from admin.introspection.core.impl.processor.introspect import IntrospectHandler from admin.introspection.impl.model import ModelService support.listenToEntities(IModelService, listeners=registerService) support.loadAllEntities(IModelService) # -------------------------------------------------------------------- @ioc.entity def assemblyIntrospection() -> Assembly: ''' The assembly used for generating the introspection models''' return Assembly('Introspection') # ---------------------------------------------------------------- @ioc.entity def introspectContexts(): return []
''' from ..cdm import contentDeliveryManager from ..plugin.registry import addService from .db_internationalization import bindInternationalizationSession, \ bindInternationalizationValidations from ally.cdm.spec import ICDM from ally.cdm.support import ExtendPathCDM from ally.container import support, ioc, bind from internationalization.scanner import Scanner # -------------------------------------------------------------------- SERVICES = 'internationalization.api.**.I*Service' @ioc.entity def binders(): return [bindInternationalizationSession] bind.bindToEntities('internationalization.impl.**.*Alchemy', binders=binders) support.createEntitySetup('internationalization.impl.**.*', 'internationalization.*.impl.**.*', Scanner) support.listenToEntities(SERVICES, listeners=addService(bindInternationalizationValidations), beforeBinding=False) support.loadAllEntities(SERVICES) # -------------------------------------------------------------------- @ioc.entity def cdmLocale() -> ICDM: ''' The content delivery manager (CDM) for the locale files. ''' return ExtendPathCDM(contentDeliveryManager(), 'cache/locale/%s')
''' Created on Jan 9, 2012 @package: introspection @copyright: 2011 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Contains the services for the introspection. ''' from ..plugin.registry import registerService from ally.container import support # -------------------------------------------------------------------- SERVICES = 'gui.*.api.**.I*Service' support.createEntitySetup('gui.*.impl.**.*') support.listenToEntities(SERVICES, listeners=registerService) support.loadAllEntities(SERVICES) # --------------------------------------------------------------------
''' Created on Mar 29, 2012 @package: simple plugin sample @copyright: 2011 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Contains the services setups. ''' from __plugin__.plugin.registry import addService from __plugin__.sample_plugin.db_sample import alchemySessionCreator from ally.container import support from ally.support.sqlalchemy.session import bindSession # -------------------------------------------------------------------- API, IMPL = 'sample_plugin.api.**.I*Service', 'sample_plugin.impl.**.*' support.createEntitySetup(API, IMPL) def bindSampleSession(proxy): bindSession(proxy, alchemySessionCreator()) support.listenToEntities(IMPL, listeners=addService(bindSampleSession,)) support.loadAllEntities(API)
# -------------------------------------------------------------------- log = logging.getLogger(__name__) # -------------------------------------------------------------------- try: from __setup__ import ally_core # @UnusedImport except ImportError: log.info('No ally core component available, cannot register the introspection') else: from __setup__.ally_core.resources import injectorAssembly from admin.introspection.core.impl.processor.index_model import IndexModelHandler from admin.introspection.core.impl.processor.introspect import IntrospectHandler from admin.introspection.impl.model import ModelService support.listenToEntities(IModelService, listeners=registerService) support.loadAllEntities(IModelService) # -------------------------------------------------------------------- @ioc.entity def assemblyIntrospection() -> Assembly: ''' The assembly used for generating the introspection models''' return Assembly('Introspection') # ---------------------------------------------------------------- @ioc.entity def introspectContexts(): return [] @ioc.entity
''' Created on Jan 9, 2012 @package: livedesk @copyright: 2012 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Contains the services for livedesk. ''' from ..plugin.registry import addService from ally.container import support from ..superdesk.db_superdesk import bindSuperdeskSession, bindSuperdeskValidations # -------------------------------------------------------------------- API, IMPL = 'livedesk.api.**.I*Service', 'livedesk.impl.**.*' support.createEntitySetup(API, IMPL) support.bindToEntities(IMPL, binders=bindSuperdeskSession) support.listenToEntities(IMPL, listeners=addService(bindSuperdeskSession, bindSuperdeskValidations)) support.loadAllEntities(API) # --------------------------------------------------------------------
""" from ..acl import gui from ..gui_action.service import addAction from ..gui_core.gui_core import publishedURI from ..media_archive.actions import modulesAction as mediaArchiveAction from ally.container import ioc, support from gui.action.api.action import Action from superdesk.media_archive.api.video_data import IVideoDataService from superdesk.media_archive.api.video_info import IVideoInfoService from ally.internationalization import NC_ from acl.right_action import RightAction # -------------------------------------------------------------------- support.listenToEntities(Action, listeners=addAction) support.loadAllEntities(Action) # -------------------------------------------------------------------- @ioc.entity def modulesAction() -> Action: """ register image plugin on media archive actions """ return Action( "video", Parent=mediaArchiveAction(), Script=publishedURI("media-archive-video/scripts/js/media-archive/") )
def addMetaDataHandler(handler): if not isinstance(handler, IMetaDataService): metaDataHandlers().append(handler) @ioc.entity def binders(): return [bindSuperdeskSession] bind.bindToEntities('superdesk.media_archive.core.impl.**.*Alchemy', binders=binders) support.createEntitySetup('superdesk.media_archive.core.impl.**.*') support.listenToEntities(IMetaDataHandler, listeners=addMetaDataHandler, beforeBinding=False, module=service) support.loadAllEntities(IMetaDataHandler, module=service) # -------------------------------------------------------------------- @ioc.config def use_solr_search(): ''' If true then the media archive search is made using solr''' return False # --------------------------------------------------------------------
''' Created on Jan 9, 2012 @package: livedesk @copyright: 2012 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Contains the services for livedesk. ''' from ..plugin.registry import addService from ally.container import support from ..superdesk.db_superdesk import bindSuperdeskSession, bindSuperdeskValidations # -------------------------------------------------------------------- SERVICES = 'livedesk.api.**.I*Service' support.createEntitySetup('livedesk.impl.**.*') support.bindToEntities('livedesk.impl.**.*Alchemy', binders=bindSuperdeskSession) support.listenToEntities(SERVICES, listeners=addService(bindSuperdeskSession, bindSuperdeskValidations)) support.loadAllEntities(SERVICES) # --------------------------------------------------------------------
''' Created on Mar 29, 2012 @package: simple plugin sample @copyright: 2011 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Contains the services setups. ''' from __plugin__.plugin.registry import addService from __plugin__.sample_plugin.db_sample import alchemySessionCreator from ally.container import support from ally.support.sqlalchemy.session import bindSession # -------------------------------------------------------------------- API, IMPL = 'sample_plugin.api.**.I*Service', 'sample_plugin.impl.**.*' support.createEntitySetup(API, IMPL) def bindSampleSession(proxy): bindSession(proxy, alchemySessionCreator()) support.listenToEntities(IMPL, listeners=addService(bindSampleSession, )) support.loadAllEntities(API)