コード例 #1
0
ファイル: webcherrypy.py プロジェクト: Lawouach/conductor
 def mount(self, script_name, app, conf=None):
     webapp = None
     try:
         _conf = self.conf.copy()
         _cpconfig.merge(_conf, self.conf)   
         webapp = cherrypy.tree.mount(app, script_name, _conf)
         self.bus.log("Mounted web application '%s' at '%s'" % (app.__class__, script_name or '/'))
     except:
         cherrypy.log("Failed mounting '%s' at '%s'" % (app.__class__, script_name or '/'),
                      traceback=True)
     else:
         if webapp:
             self.bus.publish("mounted-webapp", webapp)
コード例 #2
0
ファイル: webcherrypy.py プロジェクト: Lawouach/conductor
 def mount(self, script_name, app, conf=None):
     webapp = None
     try:
         _conf = self.conf.copy()
         _cpconfig.merge(_conf, self.conf)
         webapp = cherrypy.tree.mount(app, script_name, _conf)
         self.bus.log("Mounted web application '%s' at '%s'" %
                      (app.__class__, script_name or '/'))
     except:
         cherrypy.log("Failed mounting '%s' at '%s'" %
                      (app.__class__, script_name or '/'),
                      traceback=True)
     else:
         if webapp:
             self.bus.publish("mounted-webapp", webapp)
コード例 #3
0
ファイル: base.py プロジェクト: UncleRus/cherryBase
    def add (self, path, handler, config = None):
        stripped_path = path.strip ('/')
        path_list = stripped_path.split ('/') if stripped_path else []

        if self.handler_exists (path_list):
            raise AttributeError ('Path "{0}" is busy in "{1}"'.format (path, self.owner.name))

        if config:
            if not hasattr (handler, '_cp_config'):
                handler._cp_config = {}
            _cpconfig.merge (handler._cp_config, config)

        handler._cp_mount_path = '/' + stripped_path
        if not path_list:
            self.root = handler
        else:
            setattr (self.find_owner (path_list [0:-1]), path_list [-1], handler)
        cherrypy.log.error ('{} mounted on "{}" in "{}"'.format (type (handler).__name__, path, self.owner.name), 'TREE')
コード例 #4
0
ファイル: base.py プロジェクト: UncleRus/chips
    def add(self, path, handler, config=None):
        stripped_path = path.strip('/')
        path_list = stripped_path.split('/') if stripped_path else []

        if self._handler_exists(path_list):
            raise AttributeError('Path `%s` is busy' % path)

        if config:
            if not hasattr(handler, '_cp_config'):
                handler._cp_config = {}
            _cpconfig.merge(handler._cp_config, config)

        handler._cp_mount_path = '/' + stripped_path
        if not path_list:
            self.root = handler
        else:
            setattr(self._find_owner(path_list[0:-1]), path_list[-1], handler)
        cherrypy.log.error('%s mounted on `%s`' %
                           (type(handler).__name__, path), 'TREE')
コード例 #5
0
ファイル: __init__.py プロジェクト: UncleRus/morfi
def get_applications (mode, basename):
    import controllers

    _cpconfig.merge (
        config,
        pkg_resources.resource_filename (__package__, '__config__/%s.conf' % mode)
    )
    conf = config.get ('main', {})

    db.auto_config (config, __package__, '', 'db')
    #alchemy.wrap (__package__)

    app = cherrybase.Application (
        name = __package__,
        vhosts = conf.get ('vhosts', '.'.join ((__package__, basename))),
        config = config,
        routes = (
            ('/', controllers.Example (), None),
       )
    )
    return app
コード例 #6
0
    def add(self, path, handler, config=None):
        stripped_path = path.strip('/')
        path_list = stripped_path.split('/') if stripped_path else []

        if self.handler_exists(path_list):
            raise AttributeError('Path "{0}" is busy in "{1}"'.format(
                path, self.owner.name))

        if config:
            if not hasattr(handler, '_cp_config'):
                handler._cp_config = {}
            _cpconfig.merge(handler._cp_config, config)

        handler._cp_mount_path = '/' + stripped_path
        if not path_list:
            self.root = handler
        else:
            setattr(self.find_owner(path_list[0:-1]), path_list[-1], handler)
        cherrypy.log.error(
            '{} mounted on "{}" in "{}"'.format(
                type(handler).__name__, path, self.owner.name), 'TREE')
コード例 #7
0
ファイル: __init__.py プロジェクト: oleg-golovanov/cherryBase
def get_applications(mode, basename):
    from cherrypy import _cpconfig
    from cherrybase import Application, db, orm
    from cherrybase.db.drivers.pgsql import PgSql
    from cherrybase.orm.drivers.alchemy import SqlAlchemy
    import pkg_resources

    # Читаем конфиг
    config = {}
    _cpconfig.merge(
        config,
        pkg_resources.resource_filename(__package__,
                                        'config/{}.conf'.format(mode)))

    def get_conf_global(entry, default):
        return config.get('/', {}).get(entry, default)

    # Добавляем в каталог пулов БД нашу
    db.catalog['test'] = PgSql(host=get_conf_global('db_host', '127.0.0.1'),
                               port=get_conf_global('db_port', '5432'),
                               dbname=get_conf_global('db_name', ''),
                               user=get_conf_global('db_user', 'postgres'),
                               password=get_conf_global(
                                   'db_password', 'secret'))

    orm.catalog['test'] = SqlAlchemy('test')

    engine = cherrypy.engine
    engine.task_manager.add('test', test_bg_job, 60)

    # Возвращаем экземпляр приложения или список экземпляров
    return Application(name='test',
                       vhosts=[
                           vhost + basename if vhost[-1] == '.' else vhost
                           for vhost in _vhosts
                       ],
                       config=config,
                       routes=(('/', controllers.RootController(), None), ))
コード例 #8
0
ファイル: _cptree.py プロジェクト: cherrypy/cherrypy
    def merge(self, config):
        """Merge the given config into self.config."""
        _cpconfig.merge(self.config, config)

        # Handle namespaces specified in config.
        self.namespaces(self.config.get('/', {}))
コード例 #9
0
    def merge(self, config):
        """Merge the given config into self.config."""
        _cpconfig.merge(self.config, config)

        # Handle namespaces specified in config.
        self.namespaces(self.config.get("/", {}))
コード例 #10
0
ファイル: _cptree.py プロジェクト: Pluckyduck/eve
 def merge(self, config):
     _cpconfig.merge(self.config, config)
     self.namespaces(self.config.get('/', {}))
コード例 #11
0
ファイル: _cptree.py プロジェクト: ddimmich/Cubulus
 def merge(self, config):
     """Merge the given config into self.config."""
     _cpconfig.merge(self.config, config)
     
     # Handle namespaces specified in config.
     _cpconfig._call_namespaces(self.config.get("/", {}), self.namespaces)
コード例 #12
0
 def merge(self, config):
     """Merge the given config into self.config."""
     _cpconfig.merge(self.config, config)
     self.namespaces(self.config.get('/', {}))
コード例 #13
0
ファイル: _cptree.py プロジェクト: R4M80MrX/eve-1
 def merge(self, config):
     _cpconfig.merge(self.config, config)
     self.namespaces(self.config.get('/', {}))
コード例 #14
0
ファイル: _cptree.py プロジェクト: bennn/retic_performance
    def merge(self, config:Dict(str, Dyn)):
        """Merge the given config into self.config."""
        _cpconfig.merge(self.config, config)

        # Handle namespaces specified in config.
        self.namespaces(self.config.get("/", {}))