# -------------------------------------------------------------------- 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
from livedesk.core.spec import IBlogCollaboratorGroupCleanupService from livedesk.impl.blog_collaborator import CollaboratorSpecification 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() # --------------------------------------------------------------------
Contains the services for captcha gateway. ''' from ..plugin.registry import registerService from .acl import captcha from acl.core.impl.processor.static_right import RegisterStaticRights from ally.container import ioc, support from ally.design.processor.assembly import Assembly from ally.design.processor.handler import Handler # -------------------------------------------------------------------- SERVICES = 'gateway.captcha.api.**.I*Service' support.createEntitySetup('gateway.captcha.impl.**.*') support.listenToEntities(SERVICES, listeners=registerService) support.loadAllEntities(SERVICES) # -------------------------------------------------------------------- @ioc.entity def registerCaptchaRight() -> Handler: b = RegisterStaticRights() b.rights = [captcha()] return b # --------------------------------------------------------------------
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) # --------------------------------------------------------------------
Contains the services for superdesk. ''' from ..plugin.registry import addService from .db_example import bindExampleSession, bindExampleValidations from ally.container import support, bind, ioc from itertools import chain # -------------------------------------------------------------------- SERVICES = 'example.*.api.**.I*Service' # this provides the (start/rollback/commit) session processing @ioc.entity def binders(): return [bindExampleSession] # this provides validation of input data against database structure and content @ioc.entity def bindersService(): return list(chain((bindExampleValidations,), binders())) # inner binding; for implementation services together with alchemy database classes bind.bindToEntities('example.*.impl.**.*Alchemy', binders=binders) # inner binding; for implementation services support.createEntitySetup('example.*.impl.**.*') # outer binding; for API registering support.listenToEntities(SERVICES, listeners=addService(bindersService)) # outer binding; assuring that all APIs are registered support.loadAllEntities(SERVICES) # --------------------------------------------------------------------
@license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Ioan v. Pocol Contains the service setups. ''' from ally.container import support, ioc, bind from __plugin__.superdesk.db_superdesk import bindSuperdeskSession,\ bindSuperdeskValidations from itertools import chain from __plugin__.plugin.registry import addService # -------------------------------------------------------------------- @ioc.entity def binders(): return [bindSuperdeskSession] @ioc.entity def bindersService(): return list(chain((bindSuperdeskValidations,), binders())) SERVICES = 'support_testing.api.**.I*Service' bind.bindToEntities('support_testing.impl.**.*Service', binders=binders) support.createEntitySetup('support_testing.impl.**.*') support.listenToEntities(SERVICES, listeners=addService(bindersService)) support.loadAllEntities(SERVICES)
log = logging.getLogger(__name__) # -------------------------------------------------------------------- try: from .. import security except ImportError: log.info('No security plugin available, thus no support available for it') else: security = security # Just to avoid the import warning # ---------------------------------------------------------------- from acl.core.impl.synchronizer import SynchronizerRights from security.api.right import IRightService support.createEntitySetup(SynchronizerRights) # ---------------------------------------------------------------- def rightId(aclRight): ''' Provides the security right id for the provided acl right. @param aclRight: RightAcl The acl right to provide the id for. @return: integer The id of the security right. ''' assert isinstance(aclRight, RightAcl), 'Invalid right %s' % aclRight assert isinstance(aclRight.type,
@license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Mugur Rus Contains the services for content packager. ''' from ..plugin.registry import addService from ..superdesk.db_superdesk import bindSuperdeskSession, bindSuperdeskValidations from ally.container import support, bind, ioc from itertools import chain # -------------------------------------------------------------------- SERVICES = 'content.packager.api.**.I*Service' @ioc.entity def binders(): return [bindSuperdeskSession] @ioc.entity def bindersService(): return list(chain((bindSuperdeskValidations, ), binders())) bind.bindToEntities('content.packager.impl.**.*Alchemy', binders=binders) support.createEntitySetup('content.packager.impl.**.*') support.listenToEntities(SERVICES, listeners=addService(bindersService)) support.loadAllEntities(SERVICES)
''' Created on Jan 9, 2012 @package: indexing @copyright: 2012 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Contains the services for indexing. ''' from ..plugin.registry import registerService from ally.container import support # -------------------------------------------------------------------- SERVICES = 'indexing.api.**.I*Service' support.createEntitySetup('indexing.impl.**.*') support.listenToEntities(SERVICES, listeners=registerService) support.loadAllEntities(SERVICES)
''' Created on Dec 20, 2012 @package: url_info @copyright: 2013 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Mugur Rus Contains the services for URL info extraction. ''' from ally.container import support from ..plugin.registry import registerService # -------------------------------------------------------------------- SERVICES = 'url_info.api.*.I*Service' support.createEntitySetup('url_info.impl.**.*') support.listenToEntities(SERVICES, listeners=registerService) support.loadAllEntities(SERVICES) # --------------------------------------------------------------------
@license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Contains the setup user services. ''' from ..plugin.registry import registerService from .database import binders from ally.container import support, bind, ioc from ally.cdm.spec import ICDM from ally.cdm.support import ExtendPathCDM from __plugin__.cdm.service import contentDeliveryManager # -------------------------------------------------------------------- SERVICES = 'hr.user.api.**.I*Service' bind.bindToEntities('hr.user.impl.**.*Alchemy', binders=binders) support.createEntitySetup('hr.user.impl.**.*') support.listenToEntities(SERVICES, listeners=registerService) support.loadAllEntities(SERVICES) # -------------------------------------------------------------------- @ioc.entity def cdmAvatar() -> ICDM: ''' The content delivery manager (CDM) for the avatars. ''' return ExtendPathCDM(contentDeliveryManager(), 'avatar/%s')
SERVICES = 'content.article.api.**.I*Service' @ioc.entity def binders(): return [bindSuperdeskSession] @ioc.entity def bindersService(): return list(chain((bindSuperdeskValidations, ), binders())) bind.bindToEntities('content.article.impl.**.*Alchemy', binders=binders) support.createEntitySetup('content.article.impl.**.*') support.listenToEntities(SERVICES, listeners=addService(bindersService)) support.loadAllEntities(SERVICES) @ioc.config def article_search_provider(): ''' Specify the search provider that will be used for articles. The possible values are db for database provider and solr for solr provider''' return 'db' # -------------------------------------------------------------------- @ioc.entity def articleSearchProvider() -> IArticleSearchProvider:
''' 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)
# -------------------------------------------------------------------- try: from __setup__ import ally_core # @UnusedImport except ImportError: log.info( 'No ally core component available, thus no need to register ACL assemblers to it' ) else: from __setup__.ally_core.resources import assemblyAssembler, updateAssemblyAssembler, processMethod from acl.core.impl.processor import assembler # The assembler processors processFilter = indexFilter = indexAccess = support.notCreated # Just to avoid errors support.createEntitySetup(assembler) # ---------------------------------------------------------------- @ioc.after(updateAssemblyAssembler) def updateAssemblyAssemblerForFilter(): assemblyAssembler().add(processFilter(), before=processMethod()) @ioc.after(updateAssemblySQLAssembler) def updateAssemblySQLAssemblerForFilter(): assemblySQLAssembler().add(processFilter(), before=processMethod()) @app.setup(app.CHANGED) def updateAssemblyAssemblerForAccess(): assemblyAssembler().add(transaction(), indexFilter(), indexAccess())
@author: Ioan v. Pocol Contains the services for livedesk SEO. ''' from ally.container import support, ioc from livedesk.core.impl.seo_sync import SeoSyncProcess from ally.cdm.spec import ICDM from ..cdm import contentDeliveryManager from ..livedesk_embed.gui import embed_server_url # -------------------------------------------------------------------- seoSynchronizer = support.notCreated support.createEntitySetup(SeoSyncProcess) # -------------------------------------------------------------------- @ioc.entity def htmlCDM() -> ICDM: return contentDeliveryManager() @ioc.before(seoSynchronizer) def updateSeoSyncProcess(): seoSynchronizer().host_url = embed_server_url() # --------------------------------------------------------------------
@license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Provides the ally core setup patch. ''' from .service import assemblyCaptchaGateways, updateAssemblyCaptchaGateways from ally.container import support, ioc import logging # -------------------------------------------------------------------- log = logging.getLogger(__name__) # -------------------------------------------------------------------- try: from __setup__ import ally_core # @UnusedImport except ImportError: log.info('No ally core component available, thus cannot populate captcha gateway processors') else: from acl.core.impl.processor import resource_node_associate, resource_gateway iterateResourcePermissions = gatewaysFromPermissions = support.notCreated support.createEntitySetup(resource_node_associate.IterateResourcePermissions, resource_gateway.GatewaysFromPermissions) # -------------------------------------------------------------------- @ioc.after(updateAssemblyCaptchaGateways) def updateAssemblyCaptchaGatewaysForResources(): assemblyCaptchaGateways().add(iterateResourcePermissions(), gatewaysFromPermissions())
''' Created on April 26, 2013 @package: livedesk @copyright: 2013 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Mugur Rus Contains the services for livedesk sync. ''' from ally.container import support from livedesk.core.impl.chained_sync import ChainedSyncProcess # -------------------------------------------------------------------- support.createEntitySetup(ChainedSyncProcess)
''' 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 ..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) # --------------------------------------------------------------------
@copyright: 2014 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Ioan v. Pocol Contains the services for livedesk SEO. ''' from ally.container import support, ioc from livedesk.core.impl.seo_sync import SeoSyncProcess from ally.cdm.spec import ICDM from ..cdm import contentDeliveryManager from ..livedesk_embed.gui import embed_server_url # -------------------------------------------------------------------- seoSynchronizer = support.notCreated support.createEntitySetup(SeoSyncProcess) # -------------------------------------------------------------------- @ioc.entity def htmlCDM() -> ICDM: return contentDeliveryManager() @ioc.before(seoSynchronizer) def updateSeoSyncProcess(): seoSynchronizer().host_url = embed_server_url() # --------------------------------------------------------------------
log.info( 'No ally core http component available, thus cannot populate configurations and processors' ) else: ally_core_http = ally_core_http # Just to avoid the import warning # ---------------------------------------------------------------- from .patch_ally_core import gatewaysFromPermissions, updateAssemblyGatewaysForResources, \ iterateResourcePermissions, modelFiltersForPermissions, alternateNavigationPermissions, userValueForFilter, \ alternateNavigationPermissions from __setup__.ally_core_http.processor import assemblyResources, encoderPathResource from __setup__.ally_core.processor import invoking from superdesk.security.core.impl.processor import user_persistence_filter userPersistenceForPermissions = invokingFilter = support.notCreated # Just to avoid errors support.createEntitySetup(user_persistence_filter) # -------------------------------------------------------------------- @ioc.entity def encoderPathGateway() -> Handler: return restructure(encoderPathResource(), ('response', 'solicitation'), ('request', 'solicitation')) @ioc.entity def assemblyPermissions() -> Assembly: ''' Assembly used for creating resource permissions''' return Assembly('Resource permissions') # --------------------------------------------------------------------
from ally.container import support, bind, ioc from itertools import chain # -------------------------------------------------------------------- SERVICES = 'example.*.api.**.I*Service' # this provides the (start/rollback/commit) session processing @ioc.entity def binders(): return [bindExampleSession] # this provides validation of input data against database structure and content @ioc.entity def bindersService(): return list(chain((bindExampleValidations, ), binders())) # inner binding; for implementation services together with alchemy database classes bind.bindToEntities('example.*.impl.**.*Alchemy', binders=binders) # inner binding; for implementation services support.createEntitySetup('example.*.impl.**.*') # outer binding; for API registering support.listenToEntities(SERVICES, listeners=addService(bindersService)) # outer binding; assuring that all APIs are registered support.loadAllEntities(SERVICES) # --------------------------------------------------------------------
@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.**.*') bind.bindToEntities('general_setting.impl.**.*Alchemy', binders=binders) support.createEntitySetup('general_setting.impl.**.*') support.listenToEntities(SERVICES, listeners=addService(bindersService)) support.loadAllEntities(SERVICES) # -------------------------------------------------------------------- @ioc.entity def blogThemeCDM() -> ICDM: return contentDeliveryManager() # --------------------------------------------------------------------
""" Created on April 26, 2013 @package: livedesk @copyright: 2013 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Mugur Rus Contains the services for livedesk sync. """ from ally.container import support from livedesk.core.impl.chained_sync import ChainedSyncProcess # -------------------------------------------------------------------- support.createEntitySetup(ChainedSyncProcess)
''' 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 # -------------------------------------------------------------------- introspect = support.notCreated # Just to avoid errors SERVICES = 'admin.**.api.**.I*Service' support.createEntitySetup('admin.**.impl.**.*') support.listenToEntities(SERVICES, listeners=registerService) support.loadAllEntities(SERVICES)
# -------------------------------------------------------------------- try: from __setup__ import ally_core except ImportError: log.info( 'No ally core component available, thus cannot populate processors') else: ally_core = ally_core # Just to avoid the import warning # ---------------------------------------------------------------- from acl.core.impl.processor import resource_node_associate, resource_model_filter, resource_alternate, resource_gateway iterateResourcePermissions = checkResourceAvailableRights = modelFiltersForPermissions = \ authenticatedForPermissions = alternateNavigationPermissions = gatewaysFromPermissions = support.notCreated support.createEntitySetup(resource_node_associate, resource_model_filter, resource_alternate, resource_gateway) # -------------------------------------------------------------------- @ioc.after(updateAssemblyGateways) def updateAssemblyGatewaysForResources(): assemblyGateways().add(iterateResourcePermissions(), authenticatedForPermissions(), userValueForFilter(), alternateNavigationPermissions(), gatewaysFromPermissions(), before=registerMethodOverride()) @ioc.after(updateAssemblyActiveRights) def updateAssemblyActiveRightsForResources(): assemblyActiveRights().add(checkResourceAvailableRights(),
from gateway.core.impl.processor import method_override_gateway from sched import scheduler from security.rbac.core.impl.processor import rbac_right from superdesk.security.core.impl.processor import user_rbac_provider, \ user_filter_value from superdesk.security.core.spec import ICleanupService from superdesk.security.impl.filter_authenticated import \ AuthenticatedFilterService from threading import Thread import time # -------------------------------------------------------------------- userRbacProvider = userValueForFilter = registerMethodOverride = rbacPopulateRights = \ registerDefaultRights = support.notCreated # Just to avoid errors support.createEntitySetup(user_rbac_provider, user_filter_value, method_override_gateway, rbac_right, default_right) # -------------------------------------------------------------------- @ioc.config def cleanup_timeout() -> int: ''' The number of seconds at which to run the cleanup for sessions and authentications. ''' return 180 # -------------------------------------------------------------------- @ioc.entity def equaliltyUserFilterClasses() -> list: ''' The @see: IAclFilter classes that checks if the authenticated identifier is same with the resource identifier'''
# -------------------------------------------------------------------- log = logging.getLogger(__name__) # -------------------------------------------------------------------- try: from .. import security except ImportError: log.info('No security plugin available, thus no support available for it') else: security = security # Just to avoid the import warning # ---------------------------------------------------------------- from acl.core.impl.synchronizer import SynchronizerRights from security.api.right import IRightService support.createEntitySetup(SynchronizerRights) # ---------------------------------------------------------------- def rightId(aclRight): ''' Provides the security right id for the provided acl right. @param aclRight: RightAcl The acl right to provide the id for. @return: integer The id of the security right. ''' assert isinstance(aclRight, RightAcl), 'Invalid right %s' % aclRight assert isinstance(aclRight.type, TypeAcl), 'Invalid right %s, has no type' % aclRight
from ally.container import support, bind, ioc from itertools import chain from content.article.api.search_provider import IArticleSearchProvider from content.article.impl.db_search import SqlArticleSearchProvider # -------------------------------------------------------------------- SERVICES = 'content.article.api.**.I*Service' @ioc.entity def binders(): return [bindSuperdeskSession] @ioc.entity def bindersService(): return list(chain((bindSuperdeskValidations,), binders())) bind.bindToEntities('content.article.impl.**.*Alchemy', binders=binders) support.createEntitySetup('content.article.impl.**.*') support.listenToEntities(SERVICES, listeners=addService(bindersService)) support.loadAllEntities(SERVICES) @ioc.config def article_search_provider(): ''' Specify the search provider that will be used for articles. The possible values are db for database provider and solr for solr provider''' return 'db' # -------------------------------------------------------------------- @ioc.entity def articleSearchProvider() -> IArticleSearchProvider: if article_search_provider() == 'solr': from content.article.impl.solr_search import SolrArticleSearchProvider
''' 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) # --------------------------------------------------------------------
RegisterCompensatePermissionHandler from acl.core.impl.processor.gateway.root_uri import RootURIHandler from ally.container import ioc, support, bind from ally.container.support import entityFor from ally.design.processor.assembly import Assembly from ally.design.processor.handler import Handler # -------------------------------------------------------------------- # The gateway processors anonymousGroup = registerPermissionGateway = support.notCreated # Just to avoid errors SERVICES = 'acl.api.**.I*Service' bind.bindToEntities('acl.impl.**.*Alchemy', 'acl.core.impl.processor.gateway.**.*Alchemy', binders=binders) support.createEntitySetup('acl.impl.**.*', 'acl.core.impl.processor.gateway.**.*') support.listenToEntities(SERVICES, listeners=registerService) support.loadAllEntities(SERVICES) # -------------------------------------------------------------------- @ioc.config def root_uri_acl(): ''' The prefix used for appending to the Gateway paths. ''' return 'resources' # -------------------------------------------------------------------- @ioc.entity
from __setup__.ally.notifier import registersListeners from ally.container import ioc, support from ally.design.processor.assembly import Assembly from ally.design.processor.handler import Handler from ally.xml.digester import Node, RuleRoot from gui.core.config.impl.processor.configuration_notifier import \ ConfigurationListeners from gui.core.config.impl.processor.xml.parser import ParserHandler from gui.core.config.impl.rules import AccessRule, MethodRule, URLRule, \ ActionRule, DescriptionRule, GroupRule, RightRule # -------------------------------------------------------------------- # The synchronization processors synchronizeAction = synchronizeGroups = synchronizeRights = synchronizeGroupActions = synchronizeRightActions =\ prepareGroupAccesses = prepareRightAccesses = syncCategoryAccesses = syncGroupAccesses = syncRightAccesses = support.notCreated # Just to avoid errors support.createEntitySetup('gui.core.config.impl.processor.synchronize.**.*') # -------------------------------------------------------------------- @ioc.config def access_group(): ''' Contains the names of the access groups that are expected in the configuration file. Expected properties are name and optionally a flag indicating if actions are allowed. ''' return { 'Anonymous': dict(hasActions=True, isAnonymous=True), 'Captcha': dict(hasActions=False), 'Right': dict(hasActions=True, isRight=True) }
''' 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 April 29, 2013 @package: frontline @copyright: 2013 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Martin Saturka Contains the services for frontline. ''' from ..plugin.registry import addService from ..superdesk.db_superdesk import bindSuperdeskSession, \ bindSuperdeskValidations from ally.container import support, bind, ioc from itertools import chain # -------------------------------------------------------------------- SERVICES = 'frontline.*.api.**.I*Service' @ioc.entity def binders(): return [bindSuperdeskSession] @ioc.entity def bindersService(): return list(chain((bindSuperdeskValidations,), binders())) bind.bindToEntities('frontline.*.impl.**.*Alchemy', binders=binders) support.createEntitySetup('frontline.*.impl.**.*') support.listenToEntities(SERVICES, listeners=addService(bindersService)) support.loadAllEntities(SERVICES) # --------------------------------------------------------------------
@copyright: 2013 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Mugur Rus Contains the services for content publisher. ''' from ..plugin.registry import addService from ..superdesk.db_superdesk import bindSuperdeskSession, bindSuperdeskValidations from ally.container import support, bind, ioc from itertools import chain # -------------------------------------------------------------------- SERVICES = 'content.publisher.api.**.I*Service' @ioc.entity def binders(): return [bindSuperdeskSession] @ioc.entity def bindersService(): return list(chain((bindSuperdeskValidations, ), binders())) bind.bindToEntities('content.publisher.impl.**.*Alchemy', binders=binders) support.createEntitySetup('content.publisher.impl.**.*') support.listenToEntities(SERVICES, listeners=addService(bindersService)) support.loadAllEntities(SERVICES)
''' Created on April 26, 2013 @package: livedesk @copyright: 2013 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Mugur Rus Contains the services for livedesk sync. ''' from ally.container import support from livedesk.core.impl.blog_sync import BlogSyncProcess # -------------------------------------------------------------------- support.createEntitySetup(BlogSyncProcess)
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.**.*") bind.bindToEntities("general_setting.impl.**.*Alchemy", binders=binders) support.createEntitySetup("general_setting.impl.**.*") support.listenToEntities(SERVICES, listeners=addService(bindersService)) support.loadAllEntities(SERVICES) # -------------------------------------------------------------------- @ioc.entity def blogThemeCDM() -> ICDM: return contentDeliveryManager()
''' Created on Jan 9, 2012 @package: security @copyright: 2012 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Contains the services for security. ''' from ..plugin.registry import registerService from .database import binders from ally.container import support, bind, ioc # -------------------------------------------------------------------- SERVICES = 'security.api.**.I*Service', 'security.**.api.**.I*Service' bind.bindToEntities('security.impl.**.*Alchemy', 'security.**.impl.**.*Alchemy', binders=binders) support.createEntitySetup('security.impl.**.*', 'security.**.impl.**.*') support.listenToEntities(*SERVICES, listeners=registerService) support.loadAllEntities(*SERVICES) # -------------------------------------------------------------------- @ioc.entity def signaturesRight() -> dict: ''' The right signatures that can be injected''' return {}
from superdesk.media_archive.core.spec import IThumbnailManager, QueryIndexer from superdesk.media_archive.impl.meta_data import IMetaDataHandler, \ MetaDataServiceAlchemy from superdesk.media_archive.impl.query_criteria import QueryCriteriaService import logging # -------------------------------------------------------------------- log = logging.getLogger(__name__) # -------------------------------------------------------------------- def addMetaDataHandler(handler): if not isinstance(handler, IMetaDataService): metaDataHandlers().append(handler) support.createEntitySetup('superdesk.media_archive.core.impl.**.*') support.bindToEntities('superdesk.media_archive.core.impl.**.*Alchemy', binders=bindSuperdeskSession) support.listenToEntities(IMetaDataHandler, listeners=addMetaDataHandler, beforeBinding=False, module=service) loadAllMetaDataHandlers = support.loadAllEntities(IMetaDataHandler, module=service) # -------------------------------------------------------------------- @ioc.entity def delivery() -> IDelivery: d = HTTPDelivery() d.serverURI = server_uri() d.repositoryPath = repository_path() return d @ioc.entity def contentDeliveryManager() -> ICDM:
Contains the services for captcha gateway. ''' from ..plugin.registry import registerService from .acl import captcha from acl.core.impl.processor.static_right import RegisterStaticRights from ally.container import ioc, support from ally.design.processor.assembly import Assembly from ally.design.processor.handler import Handler # -------------------------------------------------------------------- SERVICES = 'gateway.captcha.api.**.I*Service' support.createEntitySetup('gateway.captcha.impl.**.*') support.listenToEntities(SERVICES, listeners=registerService) support.loadAllEntities(SERVICES) # -------------------------------------------------------------------- @ioc.entity def registerCaptchaRight() -> Handler: b = RegisterStaticRights() b.rights = [captcha()] return b # -------------------------------------------------------------------- @ioc.entity def assemblyCaptchaGateways() -> Assembly:
''' Created on Jan 9, 2012 @package: security @copyright: 2012 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Contains the services for security. ''' from ..plugin.registry import addService from .db_security import bindSecuritySession, bindSecurityValidations from ally.container import support, ioc, bind from itertools import chain # -------------------------------------------------------------------- SERVICES = 'security.api.**.I*Service', 'security.**.api.**.I*Service' @ioc.entity def binders(): return [bindSecuritySession] @ioc.entity def bindersService(): return list(chain((bindSecurityValidations,), binders())) bind.bindToEntities('security.impl.**.*Alchemy', 'security.**.impl.**.*Alchemy', binders=binders) support.createEntitySetup('security.impl.**.*', 'security.**.impl.**.*') support.listenToEntities(*SERVICES, listeners=addService(bindersService)) support.loadAllEntities(*SERVICES)
''' Created on Feb 23, 2012 @package: ally actions gui @copyright: 2011 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Mihai Balaceanu Provides the services setup. ''' from ..plugin.registry import registerService from .database import binders from ally.container import support, bind # -------------------------------------------------------------------- SERVICES = 'gui.action.api.**.I*Service' bind.bindToEntities('gui.action.impl.**.*Alchemy', binders=binders) support.createEntitySetup('gui.action.impl.**.*') support.listenToEntities(SERVICES, listeners=registerService) support.loadAllEntities(SERVICES) # --------------------------------------------------------------------
from ally.container import ioc, support, bind from ally.container.support import entityFor from ally.design.processor.assembly import Assembly from ally.design.processor.handler import Handler # -------------------------------------------------------------------- # The gateway processors anonymousGroup = registerPermissionGateway = support.notCreated # Just to avoid errors SERVICES = 'acl.api.**.I*Service' bind.bindToEntities('acl.impl.**.*Alchemy', 'acl.core.impl.processor.gateway.**.*Alchemy', binders=binders) support.createEntitySetup('acl.impl.**.*', 'acl.core.impl.processor.gateway.**.*') support.listenToEntities(SERVICES, listeners=registerService) support.loadAllEntities(SERVICES) # -------------------------------------------------------------------- @ioc.config def root_uri_acl(): ''' The prefix used for appending to the Gateway paths. ''' return 'resources' # --------------------------------------------------------------------
from .db_internationalization import bindInternationalizationSession, \ bindInternationalizationValidations, createTables from ally.container import support, ioc from cdm.spec import ICDM 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 # --------------------------------------------------------------------
from ..plugin.registry import registerService from ally.container import support, ioc from ally.container.support import nameInEntity from ally.design.processor.assembly import Assembly 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') # --------------------------------------------------------------------
Provides the ally core setup patch. ''' from ally.container import support, ioc import logging from security.user.core.impl.processor import assembler # -------------------------------------------------------------------- log = logging.getLogger(__name__) # -------------------------------------------------------------------- try: from __setup__ import ally_core # @UnusedImport except ImportError: log.info('No ally core component available, thus no need to register user ACL assemblers to it') else: from ..gateway_acl.patch_ally_core import indexFilter, assemblyIndex, updateAssemblyIndex # The assembler processors filterUserInject = support.notCreated # Just to avoid errors support.createEntitySetup(assembler) # ---------------------------------------------------------------- @ioc.after(updateAssemblyIndex) def updateAssemblyIndexForUserFilterInject(): assemblyIndex().add(filterUserInject(), before=indexFilter())
log = logging.getLogger(__name__) asPattern = lambda rootURI: '^%s(?:/|(?=\\.)|$)(.*)' % re.escape(rootURI) # Make the root URI into a gateway pattern. # -------------------------------------------------------------------- registerDatabaseGateway = gatewayMethodMerge = registerMethodOverride = support.notCreated # Just to avoid errors SERVICES = 'gateway.api.**.I*Service' bind.bindToEntities('gateway.impl.**.*Alchemy', 'gateway.core.impl.**.*Alchemy', binders=binders) support.createEntitySetup('gateway.impl.**.*', 'gateway.core.impl.**.*') support.listenToEntities(SERVICES, listeners=registerService) support.loadAllEntities(SERVICES) # -------------------------------------------------------------------- @ioc.entity def assemblyAnonymousGateways() -> Assembly: ''' The assembly used for generating anonymous gateways''' return Assembly('Anonymous gateways') # --------------------------------------------------------------------
''' Created on Jan 10, 2013 @package: distribution manager @copyright: 2011 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Gabriel Nistor Provides the deploy setup for distribution management. ''' from distribution.container import app from distribution.core.spec import IDistributionManager from ally.container import ioc, support # -------------------------------------------------------------------- support.createEntitySetup('distribution.**.impl.**.*') app.registerSupport() # -------------------------------------------------------------------- @ioc.start(priority= -1) # The lowest priority def deploy(): support.entityFor(IDistributionManager).deploy()
''' 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 11, 2013 @package: content packager @copyright: 2013 Sourcefabric o.p.s. @license: http://www.gnu.org/licenses/gpl-3.0.txt @author: Mugur Rus Contains the services for content packager. ''' from ..plugin.registry import addService from ..superdesk.db_superdesk import bindSuperdeskSession, bindSuperdeskValidations from ally.container import support, bind, ioc from itertools import chain # -------------------------------------------------------------------- SERVICES = 'content.packager.api.**.I*Service' @ioc.entity def binders(): return [bindSuperdeskSession] @ioc.entity def bindersService(): return list(chain((bindSuperdeskValidations,), binders())) bind.bindToEntities('content.packager.impl.**.*Alchemy', binders=binders) support.createEntitySetup('content.packager.impl.**.*') support.listenToEntities(SERVICES, listeners=addService(bindersService)) support.loadAllEntities(SERVICES)
try: from __setup__ import ally_core_http except ImportError: log.info('No ally core http component available, thus cannot populate configurations and processors') else: ally_core_http = ally_core_http # Just to avoid the import warning # ---------------------------------------------------------------- from .patch_ally_core import gatewaysFromPermissions, updateAssemblyGatewaysForResources, \ iterateResourcePermissions, modelFiltersForPermissions, alternateNavigationPermissions, userValueForFilter, \ alternateNavigationPermissions from __setup__.ally_core_http.processor import assemblyResources, encoderPathResource from __setup__.ally_core.processor import invoking from superdesk.security.core.impl.processor import user_persistence_filter userPersistenceForPermissions = invokingFilter = support.notCreated # Just to avoid errors support.createEntitySetup(user_persistence_filter) # -------------------------------------------------------------------- @ioc.entity def encoderPathGateway() -> Handler: return restructure(encoderPathResource(), ('response', 'solicitation'), ('request', 'solicitation')) @ioc.entity def assemblyPermissions() -> Assembly: ''' Assembly used for creating resource permissions''' return Assembly('Resource permissions') # -------------------------------------------------------------------- @ioc.before(assemblyPermissions)
# -------------------------------------------------------------------- log = logging.getLogger(__name__) # -------------------------------------------------------------------- try: from __setup__ import ally_core except ImportError: log.info('No ally core component available, thus cannot populate processors') else: ally_core = ally_core # Just to avoid the import warning # ---------------------------------------------------------------- from acl.core.impl.processor import resource_node_associate, resource_model_filter, resource_alternate, resource_gateway iterateResourcePermissions = checkResourceAvailableRights = modelFiltersForPermissions = \ authenticatedForPermissions = alternateNavigationPermissions = gatewaysFromPermissions = support.notCreated support.createEntitySetup(resource_node_associate, resource_model_filter, resource_alternate, resource_gateway) # -------------------------------------------------------------------- @ioc.after(updateAssemblyGateways) def updateAssemblyGatewaysForResources(): assemblyGateways().add(iterateResourcePermissions(), authenticatedForPermissions(), userValueForFilter(), alternateNavigationPermissions(), gatewaysFromPermissions(), before=registerMethodOverride()) @ioc.after(updateAssemblyActiveRights) def updateAssemblyActiveRightsForResources(): assemblyActiveRights().add(checkResourceAvailableRights(), after=registerDefaultRights())
''' 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) # --------------------------------------------------------------------
Contains the services for frontline. ''' from ..plugin.registry import addService from ..superdesk.db_superdesk import bindSuperdeskSession, \ bindSuperdeskValidations from ally.container import support, bind, ioc from itertools import chain # -------------------------------------------------------------------- SERVICES = 'frontline.*.api.**.I*Service' @ioc.entity def binders(): return [bindSuperdeskSession] @ioc.entity def bindersService(): return list(chain((bindSuperdeskValidations, ), binders())) bind.bindToEntities('frontline.*.impl.**.*Alchemy', binders=binders) support.createEntitySetup('frontline.*.impl.**.*') support.listenToEntities(SERVICES, listeners=addService(bindersService)) support.loadAllEntities(SERVICES) # --------------------------------------------------------------------