Exemple #1
0
    def __init__(self,site):
        
        #~ site.logger.info('20130418 lino.ui.ui.ExtUI.__init__()')
        super(ExtUI,self).__init__(site)
        #~ pass
        
        #~ def before_site_startup(self,site):
        #~ logger.info('20130404 on_site_startup')
        #~ site.ui = self

        #~ logger.info("20130221 lino.ui.ExtUI.__init__()")
        pre_ui_build.send(self)
        
        #~ raise Exception("20120614")
        #~ self.pdf_renderer = PdfRenderer(self) # 20120624
        from lino.ui.render import PlainRenderer, TextRenderer
        self.plain_renderer = PlainRenderer(self)
        self.text_renderer = TextRenderer(self)
        self.reserved_names = [getattr(ext_requests,n) for n in ext_requests.URL_PARAMS]
          
        if site.use_extjs:
            from lino.extjs import ExtRenderer
            self.default_renderer = self.ext_renderer = ExtRenderer(self)
        else:
            self.default_renderer = self.plain_renderer
          
        names = set()
        for n in self.reserved_names:
            if n in names:
                raise Exception("Duplicate reserved name %r" % n)
            names.add(n)
        #~ base.UI.__init__(self)
        
        #~ trigger creation of params_layout.params_store
        #~ for res in actors.actors_list:
            #~ for ba in res.get_actions():
                #~ if ba.action.parameters:
                    #~ ba.action.params_layout.get_layout_handle(self)
        
        from lino.utils import codetime
        self.mtime = codetime()
        #~ logger.info("20130610 codetime is %s", datetime.datetime.fromtimestamp(self.mtime))
        
        post_ui_build.send(self)
        
        #~ """
        #~ setup_columns() methods may access the database
        #~ """
        #~ for res in actors.actors_list:
            #~ res.setup_columns()

        # trigger creation of params_layout.params_store
        for res in actors.actors_list:
            for ba in res.get_actions():
                if ba.action.parameters:
                    ba.action.params_layout.get_layout_handle(self)
Exemple #2
0
    def __init__(self, site):
        # logger.info("20140227 Kernel.__init__() a")
        self.pending_threads = {}
        self.site = site
        self.kernel_startup(site)

        if site.build_js_cache_on_startup is None:
            site.build_js_cache_on_startup = not (
                settings.DEBUG or is_devserver())

        web.site_setup(site)

        for a in actors.actors_list:
            if a.get_welcome_messages is not None:
                site._welcome_actors.append(a)

        pre_ui_build.send(self)

        # self.plain_renderer = PlainRenderer(self)
        self.text_renderer = TextRenderer(self)
        self.reserved_names = [getattr(constants, n)
                               for n in constants.URL_PARAMS]

        names = set()
        for n in self.reserved_names:
            if n in names:
                raise Exception("Duplicate reserved name %r" % n)
            names.add(n)

        for p in site.installed_plugins:
            if isinstance(p, LinoPlugin):
                p.on_ui_init(self)

        ui = self.site.plugins.resolve(self.site.default_ui)
        if ui is None:
            raise Exception(
                "No installed app labelled %r"
                % self.site.default_ui)
        ui.url_prefix = None
        self.default_renderer = ui.renderer

        post_ui_build.send(self)

        # trigger creation of params_layout.params_store
        for res in actors.actors_list:
            for ba in res.get_actions():
                if ba.action.params_layout is not None:
                    ba.action.params_layout.get_layout_handle(self)
Exemple #3
0
    def __init__(self, site):
        # logger.info("20140227 Kernel.__init__() a")

        # from importlib import import_module
        # # For every plugin, Lino checks whether the package contains a
        # # module named `ui` and, if yes, imports this module. The
        # # benefit of this is that all "Lino extensions" to the models
        # # can be moved out of :xfile:`models.py` into a separate file
        # # :xfile:`ui.py`.
        # # print '\n'.join([p.app_name for p in self.installed_plugins])
        # for p in site.installed_plugins:
        #     # fn = dirname(inspect.getfile(p.app_module))
        #     # fn = join(fn, 'ui.py')
        #     try:
        #         x = p.app_name + '.ui'
        #         import_module(x)
        #         logger.info("20150416 imported %s", x)
        #     except Exception as e:
        #     # except ImportError as e:
        #         if str(e) != "No module named ui":
        #             logger.warning("Failed to import %s : %s", x, e)
        #             # raise Exception("Failed to import %s : %s" % (x, e))

        self.pending_threads = {}
        self.site = site
        self.GFK_LIST = []
        self.kernel_startup(site)
        self.code_mtime = codetime()
        # We set `code_mtime` only after kernel_startup() because
        # codetime watches only those modules which are already
        # imported.

        self.memo_parser = Parser()

        def url2html(parser, s):
            url_text = s.split(None, 1)
            if len(url_text) == 1:
                url = text = url_text[0]
            else:
                url, text = url_text
            return '<a href="%s">%s</a>' % (url, text)

        self.memo_parser.register_command('url', url2html)

        if site.build_js_cache_on_startup is None:
            site.build_js_cache_on_startup = not (
                settings.DEBUG or is_devserver())

        # web.site_setup(site)

        for a in actors.actors_list:
            if a.get_welcome_messages is not None:
                # site._welcome_actors.append(a)
                site.add_welcome_handler(a.get_welcome_messages)

        pre_ui_build.send(self)

        self.html_renderer = HtmlRenderer(self)
        self.text_renderer = TextRenderer(self)
        self.reserved_names = [getattr(constants, n)
                               for n in constants.URL_PARAMS]

        names = set()
        for n in self.reserved_names:
            if n in names:
                raise Exception("Duplicate reserved name %r" % n)
            names.add(n)

        for p in site.installed_plugins:
            p.on_ui_init(self)

        ui = None
        if self.site.default_ui is not None:
            ui = self.site.plugins.resolve(self.site.default_ui)
            if ui is None:
                raise Exception(
                    "Invalid value %r for `default_ui` (must be one of %s)"
                    % (self.site.default_ui, list(self.site.plugins.keys())))
            ui.url_prefix = None
        else:
            for p in self.site.installed_plugins:
                if p.ui_handle_attr_name is not None:
                    ui = p
                    break
            # if ui is None:
            #     raise Exception("No user interface in {0}".format(
            #         [u.app_name for u in self.site.installed_plugins]))
        if ui is not None:
            self.default_renderer = ui.renderer
            self.default_ui = ui

        post_ui_build.send(self)

        if self.default_ui is not None:

            # trigger creation of params_layout.params_store
            for res in actors.actors_list:
                for ba in res.get_actions():
                    if ba.action.params_layout is not None:
                        ba.action.params_layout.get_layout_handle(
                            self.default_ui)
Exemple #4
0
    def __init__(self, site):
        # logger.info("20140227 Kernel.__init__() a")

        # from django.utils.importlib import import_module
        # # For every plugin, Lino checks whether the package contains a
        # # module named `ui` and, if yes, imports this module. The
        # # benefit of this is that all "Lino extensions" to the models
        # # can be moved out of :xfile:`models.py` into a separate file
        # # :xfile:`ui.py`.
        # # print '\n'.join([p.app_name for p in self.installed_plugins])
        # for p in site.installed_plugins:
        #     # fn = dirname(inspect.getfile(p.app_module))
        #     # fn = join(fn, 'ui.py')
        #     try:
        #         x = p.app_name + '.ui'
        #         import_module(x)
        #         logger.info("20150416 imported %s", x)
        #     except Exception as e:
        #     # except ImportError as e:
        #         if str(e) != "No module named ui":
        #             logger.warning("Failed to import %s : %s", x, e)
        #             # raise Exception("Failed to import %s : %s" % (x, e))

        self.pending_threads = {}
        self.site = site
        self.GFK_LIST = []
        self.kernel_startup(site)
        self.code_mtime = codetime()
        # We set `code_mtime` only after kernel_startup() because
        # codetime watches only those modules which are already
        # imported.

        if site.build_js_cache_on_startup is None:
            site.build_js_cache_on_startup = not (settings.DEBUG
                                                  or is_devserver())

        # web.site_setup(site)

        for a in actors.actors_list:
            if a.get_welcome_messages is not None:
                # site._welcome_actors.append(a)
                site.add_welcome_handler(a.get_welcome_messages)

        pre_ui_build.send(self)

        self.html_renderer = HtmlRenderer(self)
        self.text_renderer = TextRenderer(self)
        self.reserved_names = [
            getattr(constants, n) for n in constants.URL_PARAMS
        ]

        names = set()
        for n in self.reserved_names:
            if n in names:
                raise Exception("Duplicate reserved name %r" % n)
            names.add(n)

        for p in site.installed_plugins:
            p.on_ui_init(self)

        ui = None
        if self.site.default_ui is not None:
            ui = self.site.plugins.resolve(self.site.default_ui)
            if ui is None:
                raise Exception(
                    "Invalid value %r for `default_ui` (must be one of %s)" %
                    (self.site.default_ui, self.site.plugins.keys()))
            ui.url_prefix = None
        else:
            for p in self.site.installed_plugins:
                if p.ui_handle_attr_name is not None:
                    ui = p
                    break
            # if ui is None:
            #     raise Exception("No user interface in {0}".format(
            #         [u.app_name for u in self.site.installed_plugins]))
        if ui is not None:
            self.default_renderer = ui.renderer
            self.default_ui = ui

        post_ui_build.send(self)

        if self.default_ui is not None:

            # trigger creation of params_layout.params_store
            for res in actors.actors_list:
                for ba in res.get_actions():
                    if ba.action.params_layout is not None:
                        ba.action.params_layout.get_layout_handle(
                            self.default_ui)