Ejemplo n.º 1
0
    def __init__(self,
                 apps_dir='apps',
                 project_dir=None,
                 include_apps=None,
                 start=True,
                 default_settings=None,
                 settings_file='settings.ini',
                 local_settings_file='local_settings.ini',
                 xhr_redirect_json=True):

        global _xhr_redirect_json

        _xhr_redirect_json = xhr_redirect_json
        __global__.application = self
        self.debug = False
        self.include_apps = include_apps or []
        self.default_settings = default_settings or {}
        self.settings_file = settings_file
        self.local_settings_file = local_settings_file
        if not Dispatcher.installed:
            self.init(project_dir, apps_dir)
            dispatch.call(self, 'startup_installed')
            self.init_urls()

        if start:
            dispatch.call(self, 'startup')
Ejemplo n.º 2
0
 def __init__(self, apps_dir='apps', project_dir=None, include_apps=None, start=True, default_settings=None, settings_file='settings.ini', local_settings_file='local_settings.ini'):
     conf.application = self
     self.debug = False
     self.include_apps = include_apps or []
     self.default_settings = default_settings or {}
     self.settings_file = settings_file
     self.local_settings_file = local_settings_file
     if not Dispatcher.installed:
         self.init(project_dir, apps_dir)
         dispatch.call(self, 'startup_installed')
         self.init_urls()
         
     if start:
         dispatch.call(self, 'startup')
Ejemplo n.º 3
0
 def get_view_env(self):
     #prepare local env
     local_env = {}
     
     #process before view call
     dispatch.call(self, 'prepare_view_env', local_env, local.request)
     
     local_env['application'] = local.application
     local_env['request'] = conf.request
     local_env['response'] = conf.response
     local_env['url_for'] = url_for
     local_env['redirect'] = redirect
     local_env['error'] = error
     local_env['settings'] = conf.settings
     local_env['json'] = json
     local_env['function'] = function
     local_env['functions'] = functions
     
     return self.get_env(local_env)
Ejemplo n.º 4
0
 def get_view_env(self):
     #prepare local env
     local_env = {}
     
     #process before view call
     dispatch.call(self, 'prepare_view_env', local_env)
     
     local_env['application'] = __global__.application
     local_env['request'] = local.request
     local_env['response'] = local.response
     local_env['url_for'] = url_for
     local_env['redirect'] = redirect
     local_env['Redirect'] = Redirect
     local_env['error'] = error
     local_env['settings'] = __global__.settings
     local_env['json'] = json
     local_env['function'] = function
     local_env['functions'] = functions
     local_env['json_dumps'] = json_dumps
     
     return self.get_env(local_env)
Ejemplo n.º 5
0
    def get_view_env(self):
        # prepare local env
        local_env = {}

        # process before view call
        dispatch.call(self, "prepare_view_env", local_env)

        local_env["application"] = __global__.application
        local_env["request"] = local.request
        local_env["response"] = local.response
        local_env["url_for"] = url_for
        local_env["redirect"] = redirect
        local_env["Redirect"] = Redirect
        local_env["error"] = error
        local_env["settings"] = __global__.settings
        local_env["json"] = json
        local_env["function"] = function
        local_env["functions"] = functions
        local_env["json_dumps"] = json_dumps

        return self.get_env(local_env)
Ejemplo n.º 6
0
 def init(self, project_dir, apps_dir):
     if not project_dir:
         project_dir = norm_path(os.path.join(apps_dir, '..'))
     Dispatcher.project_dir = project_dir
     Dispatcher.apps_dir = norm_path(os.path.join(project_dir, 'apps'))
     Dispatcher.apps = get_apps(self.apps_dir, self.include_apps, self.settings_file, self.local_settings_file)
     Dispatcher.modules = self.collect_modules()
     
     self.install_settings(self.modules['settings'])
     Dispatcher.settings = settings
     
     #process domains
     self.process_domains(settings)
     
     #setup log
     self.set_log()
     
     #set app rules
     rules.set_app_rules(dict(settings.get('URL', {})))
     
     Dispatcher.env = self._prepare_env()
     Dispatcher.template_dirs = self.get_template_dirs()
     
     #begin to start apps
     self.install_apps()
     #process binds
     self.install_binds()
     dispatch.call(self, 'after_init_apps')
     #process views
     self.install_views(self.modules['views'])
     #process exposes
     self.install_exposes()
     #process middlewares
     Dispatcher.middlewares = self.install_middlewares()
     
     self.debug = settings.GLOBAL.get('DEBUG', False)
     dispatch.call(self, 'prepare_default_env', Dispatcher.env)
     Dispatcher.default_template = pkg.resource_filename('uliweb.core', 'default.html')
     
     Dispatcher.installed = True
Ejemplo n.º 7
0
    def __init__(
        self,
        apps_dir="apps",
        project_dir=None,
        include_apps=None,
        start=True,
        default_settings=None,
        settings_file="settings.ini",
        local_settings_file="local_settings.ini",
    ):

        __global__.application = self
        self.debug = False
        self.include_apps = include_apps or []
        self.default_settings = default_settings or {}
        self.settings_file = settings_file
        self.local_settings_file = local_settings_file
        if not Dispatcher.installed:
            self.init(project_dir, apps_dir)
            dispatch.call(self, "startup_installed")
            self.init_urls()

        if start:
            dispatch.call(self, "startup")
Ejemplo n.º 8
0
    def init(self, project_dir, apps_dir):
        if not project_dir:
            project_dir = norm_path(os.path.join(apps_dir, '..'))

        Dispatcher.project_dir = project_dir
        Dispatcher.apps_dir = norm_path(os.path.join(project_dir, 'apps'))
        Dispatcher.apps = get_apps(self.apps_dir, self.include_apps,
                                   self.settings_file,
                                   self.local_settings_file)
        Dispatcher.modules = self.collect_modules()

        self.install_settings(self.modules['settings'])

        #process global_objects
        self.install_global_objects()

        #process binds
        self.install_binds()

        dispatch.call(self, 'after_init_settings')

        Dispatcher.settings = settings

        #process domains
        self.process_domains(settings)

        #setup log
        self.set_log()

        #set app rules
        rules.set_app_rules(dict(settings.get('URL', {})))

        Dispatcher.env = self._prepare_env()
        Dispatcher.template_dirs = self.get_template_dirs()
        Dispatcher.template_processors = {}
        self.install_template_processors()

        #begin to start apps
        self.install_apps()
        dispatch.call(self, 'after_init_apps')
        #process views
        self.install_views(self.modules['views'])
        #process exposes
        self.install_exposes()
        #process middlewares
        Dispatcher.middlewares = self.install_middlewares()

        self.debug = settings.GLOBAL.get('DEBUG', False)
        dispatch.call(self, 'prepare_default_env', Dispatcher.env)
        Dispatcher.default_template = pkg.resource_filename(
            'uliweb.core', 'default.html')

        Dispatcher.installed = True
Ejemplo n.º 9
0
    def init(self, project_dir, apps_dir):
        if not project_dir:
            project_dir = norm_path(os.path.join(apps_dir, ".."))
        Dispatcher.project_dir = project_dir
        Dispatcher.apps_dir = norm_path(os.path.join(project_dir, "apps"))
        Dispatcher.apps = get_apps(self.apps_dir, self.include_apps, self.settings_file, self.local_settings_file)
        Dispatcher.modules = self.collect_modules()

        self.install_settings(self.modules["settings"])

        # process global_objects
        self.install_global_objects()

        # process binds
        self.install_binds()

        dispatch.call(self, "after_init_settings")

        Dispatcher.settings = settings

        # process domains
        self.process_domains(settings)

        # setup log
        self.set_log()

        # set app rules
        rules.set_app_rules(dict(settings.get("URL", {})))

        Dispatcher.env = self._prepare_env()
        Dispatcher.template_dirs = self.get_template_dirs()
        Dispatcher.template_processors = {}
        self.install_template_processors()

        # begin to start apps
        self.install_apps()
        dispatch.call(self, "after_init_apps")
        # process views
        self.install_views(self.modules["views"])
        # process exposes
        self.install_exposes()
        # process middlewares
        Dispatcher.middlewares = self.install_middlewares()

        self.debug = settings.GLOBAL.get("DEBUG", False)
        dispatch.call(self, "prepare_default_env", Dispatcher.env)
        Dispatcher.default_template = pkg.resource_filename("uliweb.core", "default.html")

        Dispatcher.installed = True