コード例 #1
0
 def loadTableScript(self, page, table=None, respath=None, class_name=None):
     """TODO
     
     :param page: TODO
     :param table: the :ref:`database table <table>` name on which the query will be executed,
                   in the form ``packageName.tableName`` (packageName is the name of the
                   :ref:`package <packages>` to which the table belongs to)
     :param respath: TODO
     :param class_name: TODO
     """
     class_name = class_name or 'Main'
     application = self.gnrapp
     if ':' in respath:
         table, respath = respath.split(':')
     if isinstance(table, basestring):
         table = application.db.table(table)
     if not table:
         tablename = '_default'
         modName = os.path.join('tables', tablename, *(respath.split('/')))
     else:
         tablename = table.name
         pkgname = table.pkg.name
         modName = os.path.join('tables', '_packages', pkgname, tablename,
                                *(respath.split('/')))
     resourceDirs = page.resourceDirs
     modPathList = self.getResourceList(resourceDirs, modName, 'py')
     if not modPathList and table is not None:
         resourceDirs = self.package_resourceDirs(table.pkg.name)
         modName = os.path.join('tables', tablename, *(respath.split('/')))
         modPathList = self.getResourceList(resourceDirs, modName, 'py')
         if not modPathList:
             tablename = '_default'
             resourceDirs = page.resourceDirs
             modName = os.path.join('tables', tablename,
                                    *(respath.split('/')))
             modPathList = self.getResourceList(resourceDirs, modName, 'py')
     modPathList = self.getResourceList(resourceDirs, modName, 'py') or []
     if modPathList:
         modPathList.reverse()
         basePath = modPathList.pop(0)
         resource_module = gnrImport(basePath, avoidDup=True)
         resource_class = getattr(resource_module, class_name, None)
         for modPath in modPathList:
             resource_module = gnrImport(modPath, avoidDup=True)
             resource_class = cloneClass('CustomResource', resource_class)
             custom_resource_class = getattr(resource_module, class_name,
                                             None)
             if resource_class:
                 classMixin(resource_class,
                            custom_resource_class,
                            only_callables=False)
         resource_obj = resource_class(page=page, resource_table=table)
         return resource_obj
     else:
         raise GnrWebServerError('Cannot import component %s' % modName)
コード例 #2
0
ファイル: gnrresourceloader.py プロジェクト: poppogbr/genropy
 def loadResource(self, pkg, *path):
     """add???
     
     :param pkg: add???
     :param \* path: add???
     :returns: add???
     """
     resourceDirs = self.package_resourceDirs(pkg)
     resource_class = cloneClass('CustomResource', BaseResource)
     resource_class.resourceDirs = resourceDirs
     self.mixinResource(resource_class, resourceDirs, *path)
     return resource_class()
コード例 #3
0
 def loadResource(self, pkg, *path):
     """add???
     
     :param pkg: add???
     :param \* path: add???
     :returns: add???
     """
     resourceDirs = self.package_resourceDirs(pkg)
     resource_class = cloneClass('CustomResource', BaseResource)
     resource_class.resourceDirs = resourceDirs
     self.mixinResource(resource_class, resourceDirs, *path)
     return resource_class()
コード例 #4
0
 def get_page_class(self, path=None, pkg=None):
     """add???
     
     :param path: add???. Default value is ``None``
     :param pkg: add???. Default value is ``None``
     :returns: add???
     """
     if pkg == '*':
         module_path = os.path.join(self.site_path, path)
         pkg = self.site.config['packages?default']
     else:
         module_path = os.path.join(self.gnrapp.packages[pkg].packageFolder, 'webpages', path)
         
     # if module_path in self.page_factories:
     #    return self.page_factories[module_path]
     page_module = gnrImport(module_path, avoidDup=True)
     page_factory = getattr(page_module, 'page_factory', GnrWebPage)
     custom_class = getattr(page_module, 'GnrCustomWebPage')
     py_requires = splitAndStrip(getattr(custom_class, 'py_requires', ''), ',')
     plugin_webpage_classes = self.plugin_webpage_classes(path, pkg=pkg)
     for plugin_webpage_class in plugin_webpage_classes:
         plugin_py_requires = splitAndStrip(getattr(plugin_webpage_class, 'py_requires', ''), ',')
         py_requires.extend(plugin_py_requires)
     page_class = cloneClass('GnrCustomWebPage', page_factory)
     page_class.__module__ = page_module
     self.page_class_base_mixin(page_class, pkg=pkg)
     page_class.dojo_version = getattr(custom_class, 'dojo_version', None) or self.site.config[
                                                                              'dojo?version'] or '11'
     page_class.theme = getattr(custom_class, 'theme', None) or self.site.config['dojo?theme'] or 'tundra'
     page_class.gnrjsversion = getattr(custom_class, 'gnrjsversion', None) or self.site.config[
                                                                              'gnrjs?version'] or '11'
     page_class.maintable = getattr(custom_class, 'maintable', None)
     page_class.recordLock = getattr(custom_class, 'recordLock', None)
     page_class.user_polling = int(
             getattr(custom_class, 'user_polling', None) or self.site.config['polling?user'] or 3)
     page_class.auto_polling = int(
             getattr(custom_class, 'auto_polling', None) or self.site.config['polling?auto'] or 30)
     page_class.eagers = getattr(custom_class, 'eagers', {})
     page_class.css_requires = []
     page_class.js_requires = splitAndStrip(getattr(custom_class, 'js_requires', ''), ',')
     page_class.pageOptions = getattr(custom_class, 'pageOptions', {})
     page_class.auth_tags = getattr(custom_class, 'auth_tags', '')
     page_class.resourceDirs = self.page_class_resourceDirs(page_class, module_path, pkg=pkg)
     self.page_pyrequires_mixin(page_class, py_requires)
     classMixin(page_class, custom_class, only_callables=False)
     page_class.css_requires.extend([x for x in splitAndStrip(getattr(custom_class, 'css_requires', ''), ',') if x])
     page_class.tpldirectories = page_class.resourceDirs + [
             self.gnr_static_handler.path(page_class.gnrjsversion, 'tpl')]
     page_class._packageId = pkg
     self.page_class_plugin_mixin(page_class, plugin_webpage_classes)
     self.page_class_custom_mixin(page_class, path, pkg=pkg)
     self.page_factories[module_path] = page_class
     return page_class
コード例 #5
0
 def loadTableScript(self, page, table=None, respath=None, class_name=None):
     """TODO
     
     :param page: TODO
     :param table: the :ref:`database table <table>` name on which the query will be executed,
                   in the form ``packageName.tableName`` (packageName is the name of the
                   :ref:`package <packages>` to which the table belongs to)
     :param respath: TODO
     :param class_name: TODO
     """
     class_name = class_name or 'Main'
     application = self.gnrapp
     if ':' in respath:
         table, respath = respath.split(':')
     if isinstance(table, basestring):
         table = application.db.table(table)
     if not table:
         tablename = '_default'
         modName = os.path.join('tables', tablename, *(respath.split('/')))
     else:
         tablename = table.name
         pkgname = table.pkg.name
         modName = os.path.join('tables','_packages',pkgname, tablename, *(respath.split('/')))
     resourceDirs = page.resourceDirs
     modPathList = self.getResourceList(resourceDirs, modName, 'py')
     if not modPathList and table is not None:
         resourceDirs = self.package_resourceDirs(table.pkg.name)
         modName = os.path.join('tables', tablename, *(respath.split('/')))
         modPathList = self.getResourceList(resourceDirs, modName, 'py')
         if not modPathList:
             tablename = '_default'
             resourceDirs = page.resourceDirs
             modName = os.path.join('tables', tablename, *(respath.split('/')))
             modPathList = self.getResourceList(resourceDirs, modName, 'py')
     modPathList = self.getResourceList(resourceDirs, modName, 'py') or []
     if modPathList:
         modPathList.reverse()
         basePath = modPathList.pop(0)
         resource_module = gnrImport(basePath, avoidDup=True)
         resource_class = getattr(resource_module, class_name, None)
         for modPath in modPathList:
             resource_module = gnrImport(modPath, avoidDup=True)
             resource_class =cloneClass('CustomResource', resource_class)
             custom_resource_class = getattr(resource_module, class_name, None)
             if resource_class:
                 classMixin(resource_class, custom_resource_class, only_callables=False)
         resource_obj = resource_class(page=page, resource_table=table)
         return resource_obj
     else:
         raise GnrWebServerError('Cannot import component %s' % modName)
コード例 #6
0
 def loadResource(self, *path, **kwargs):
     """TODO"""
     resource_class = cloneClass('CustomResource', BaseResource)
     pkg=kwargs.pop('pkg', None)
     page=kwargs.pop('page', None)
     pluginId=kwargs.pop('pluginId', None)
     pkgOnly=kwargs.pop('pkgOnly', False)
     if pkg:
         resourceDirs = self.package_resourceDirs(pkg)
         lookupDirs = self.package_resourceDirs(pkg, omitSiteResources=pkgOnly, pluginId=pluginId)
     else:
         resourceDirs = lookupDirs = page.resourceDirs
     resource_class.resourceDirs = resourceDirs
     self.mixinResource(resource_class, lookupDirs, *path)
     return resource_class()
コード例 #7
0
ファイル: gnrresourceloader.py プロジェクト: unbit/genropy
 def loadResource(self, *path, **kwargs):
     """TODO"""
     resource_class = cloneClass('CustomResource', BaseResource)
     pkg=kwargs.pop('pkg', None)
     page=kwargs.pop('page', None)
     pluginId=kwargs.pop('pluginId', None)
     pkgOnly=kwargs.pop('pkgOnly', False)
     if pkg:
         resourceDirs = self.package_resourceDirs(pkg)
         lookupDirs = self.package_resourceDirs(pkg, omitSiteResources=pkgOnly, pluginId=pluginId)
     else:
         resourceDirs = lookupDirs = page.resourceDirs
     resource_class.resourceDirs = resourceDirs
     self.mixinResource(resource_class, lookupDirs, *path)
     return resource_class()
コード例 #8
0
 def get_page_class(self, path=None, pkg=None, plugin=None,request_args=None,request_kwargs=None):
     """TODO
     
     :param path: TODO
     :param pkg: the :ref:`package <packages>` object"""
     if pkg == '*':
         module_path = os.path.join(self.site_path, path)
         pkg = self.site.config['packages?default']
     else:
         if plugin:
             module_path= os.path.join(self.gnrapp.packages[pkg].plugins[plugin].webpages_path, path)
         else:
             module_path = os.path.join(self.gnrapp.packages[pkg].packageFolder, 'webpages', path)
         
     # if module_path in self.page_factories:
     #    return self.page_factories[module_path]
     page_module = gnrImport(module_path, avoidDup=True)
     page_factory = getattr(page_module, 'page_factory', GnrWebPage)
     custom_class = getattr(page_module, 'GnrCustomWebPage')
     mainPkg = pkg
     if hasattr(custom_class,'getMainPackage'):
         kw = dict()
         if 'page_id' in request_kwargs:
             kw = self.site.register.pageStore(request_kwargs['page_id']).getItem('pageArgs') or dict()
             kw.update(request_kwargs)
         mainPkg = custom_class.getMainPackage(request_args=request_args,request_kwargs=kw)
     py_requires = splitAndStrip(getattr(custom_class, 'py_requires', ''), ',')
     plugin_webpage_classes = self.plugin_webpage_classes(path, pkg=mainPkg)
     for plugin_webpage_class in plugin_webpage_classes:
         plugin_py_requires = splitAndStrip(getattr(plugin_webpage_class, 'py_requires', ''), ',')
         py_requires.extend(plugin_py_requires)
     page_class = cloneClass('GnrCustomWebPage', page_factory)
     page_class.__module__ = page_module.__name__
     self.page_class_base_mixin(page_class, pkg=mainPkg)
     page_class.dojo_version = getattr(custom_class, 'dojo_version', None) or self.site.config[
                                                                              'dojo?version'] or '11'
     page_class.theme = getattr(custom_class, 'theme', None) or self.site.config['dojo?theme'] or 'tundra'
     page_class.gnrjsversion = getattr(custom_class, 'gnrjsversion', None) or self.site.config[
                                                                              'gnrjs?version'] or '11'
     page_class.maintable = getattr(custom_class, 'maintable', None)
     page_class.recordLock = getattr(custom_class, 'recordLock', None)
     page_class.user_polling = int(
             getattr(custom_class, 'user_polling', None) or self.site.config['polling?user'] or 3)
     page_class.auto_polling = int(
             getattr(custom_class, 'auto_polling', None) or self.site.config['polling?auto'] or 30)
     if hasattr(custom_class,'polling_enabled'):
         page_class.polling_enabled = getattr(custom_class, 'polling_enabled')
     page_class.eagers = getattr(custom_class, 'eagers', {})
     page_class.css_requires = []
     page_class.js_requires = splitAndStrip(getattr(custom_class, 'js_requires', ''), ',')
     page_class.pageOptions = getattr(custom_class, 'pageOptions', {})
     page_class.auth_tags = getattr(custom_class, 'auth_tags', '')
     page_class.resourceDirs = self.page_class_resourceDirs(page_class, module_path, pkg=mainPkg)
     self.page_pyrequires_mixin(page_class, py_requires)
     classMixin(page_class, custom_class, only_callables=False)
     page_class.css_requires.extend([x for x in splitAndStrip(getattr(custom_class, 'css_requires', ''), ',') if x])
     page_class.tpldirectories = page_class.resourceDirs + [
             self.gnr_static_handler.path(page_class.gnrjsversion, 'tpl')]
     page_class._packageId = mainPkg
     self.page_class_plugin_mixin(page_class, plugin_webpage_classes)
     self.page_class_custom_mixin(page_class, path, pkg=mainPkg)
     self.page_factories[module_path] = page_class
     return page_class
コード例 #9
0
ファイル: gnrresourceloader.py プロジェクト: poppogbr/genropy
    def get_page_class(self, path=None, pkg=None):
        """add???
        
        :param path: add???. Default value is ``None``
        :param pkg: add???. Default value is ``None``
        :returns: add???
        """
        if pkg == '*':
            module_path = os.path.join(self.site_path, path)
            pkg = self.site.config['packages?default']
        else:
            module_path = os.path.join(self.gnrapp.packages[pkg].packageFolder,
                                       'webpages', path)

        # if module_path in self.page_factories:
        #    return self.page_factories[module_path]
        page_module = gnrImport(module_path, avoidDup=True)
        page_factory = getattr(page_module, 'page_factory', GnrWebPage)
        custom_class = getattr(page_module, 'GnrCustomWebPage')
        py_requires = splitAndStrip(getattr(custom_class, 'py_requires', ''),
                                    ',')
        plugin_webpage_classes = self.plugin_webpage_classes(path, pkg=pkg)
        for plugin_webpage_class in plugin_webpage_classes:
            plugin_py_requires = splitAndStrip(
                getattr(plugin_webpage_class, 'py_requires', ''), ',')
            py_requires.extend(plugin_py_requires)
        page_class = cloneClass('GnrCustomWebPage', page_factory)
        page_class.__module__ = page_module
        self.page_class_base_mixin(page_class, pkg=pkg)
        page_class.dojo_version = getattr(
            custom_class, 'dojo_version',
            None) or self.site.config['dojo?version'] or '11'
        page_class.theme = getattr(
            custom_class, 'theme',
            None) or self.site.config['dojo?theme'] or 'tundra'
        page_class.gnrjsversion = getattr(
            custom_class, 'gnrjsversion',
            None) or self.site.config['gnrjs?version'] or '11'
        page_class.maintable = getattr(custom_class, 'maintable', None)
        page_class.recordLock = getattr(custom_class, 'recordLock', None)
        page_class.user_polling = int(
            getattr(custom_class, 'user_polling', None)
            or self.site.config['polling?user'] or 3)
        page_class.auto_polling = int(
            getattr(custom_class, 'auto_polling', None)
            or self.site.config['polling?auto'] or 30)
        page_class.eagers = getattr(custom_class, 'eagers', {})
        page_class.css_requires = []
        page_class.js_requires = splitAndStrip(
            getattr(custom_class, 'js_requires', ''), ',')
        page_class.pageOptions = getattr(custom_class, 'pageOptions', {})
        page_class.auth_tags = getattr(custom_class, 'auth_tags', '')
        page_class.resourceDirs = self.page_class_resourceDirs(page_class,
                                                               module_path,
                                                               pkg=pkg)
        self.page_pyrequires_mixin(page_class, py_requires)
        classMixin(page_class, custom_class, only_callables=False)
        page_class.css_requires.extend([
            x for x in splitAndStrip(getattr(custom_class, 'css_requires', ''),
                                     ',') if x
        ])
        page_class.tpldirectories = page_class.resourceDirs + [
            self.gnr_static_handler.path(page_class.gnrjsversion, 'tpl')
        ]
        page_class._packageId = pkg
        self.page_class_plugin_mixin(page_class, plugin_webpage_classes)
        self.page_class_custom_mixin(page_class, path, pkg=pkg)
        self.page_factories[module_path] = page_class
        return page_class
コード例 #10
0
ファイル: gnrresourceloader.py プロジェクト: unbit/genropy
    def get_page_class(self, basepath=None,relpath=None, pkg=None, plugin=None,request_args=None,request_kwargs=None):
        """TODO
        
        :param path: TODO
        :param pkg: the :ref:`package <packages>` object"""

        module_path = os.path.join(basepath,relpath)
        page_module = gnrImport(module_path, avoidDup=True,silent=False)
        page_factory = getattr(page_module, 'page_factory', GnrWebPage)
        custom_class = getattr(page_module, 'GnrCustomWebPage')
        mainPkg = pkg
        if hasattr(custom_class,'getMainPackage'):
            kw = dict()
            if 'page_id' in request_kwargs:
                kw = self.site.register.pageStore(request_kwargs['page_id']).getItem('pageArgs') or dict()
                kw.update(request_kwargs)
            mainPkg = custom_class.getMainPackage(request_args=request_args,request_kwargs=kw)
        py_requires = splitAndStrip(getattr(custom_class, 'py_requires', ''), ',')
        plugin_webpage_classes = self.plugin_webpage_classes(relpath, pkg=mainPkg)
        for plugin_webpage_class in plugin_webpage_classes:
            plugin_py_requires = splitAndStrip(getattr(plugin_webpage_class, 'py_requires', ''), ',')
            py_requires.extend(plugin_py_requires)
        page_class = cloneClass('GnrCustomWebPage', page_factory)
        page_class.__module__ = page_module.__name__
        self.page_class_base_mixin(page_class, pkg=mainPkg)
        package_py_requires = splitAndStrip(getattr(page_class, 'package_py_requires', ''), ',')
        package_js_requires = splitAndStrip(getattr(page_class, 'package_js_requires', ''), ',')
        package_css_requires = splitAndStrip(getattr(page_class, 'package_css_requires', ''), ',') 
        if package_py_requires:
            py_requires = uniquify(package_py_requires + py_requires)
        page_class.dojo_version = getattr(custom_class, 'dojo_version', None) or self.site.config[
                                                                                 'dojo?version'] or '11'
        page_class.theme = getattr(custom_class, 'theme', None) or self.site.config['dojo?theme'] or 'tundra'
        page_class.gnrjsversion = getattr(custom_class, 'gnrjsversion', None) or self.site.config[
                                                                                 'gnrjs?version'] or '11'
        page_class.maintable = getattr(custom_class, 'maintable', None)
        page_class.recordLock = getattr(custom_class, 'recordLock', None)
        page_class.user_polling = int(
                getattr(custom_class, 'user_polling', None) or self.site.config['polling?user'] or 3)
        page_class.auto_polling = int(
                getattr(custom_class, 'auto_polling', None) or self.site.config['polling?auto'] or 30)
        if hasattr(custom_class,'polling_enabled'):
            page_class.polling_enabled = getattr(custom_class, 'polling_enabled')
        page_class.eagers = getattr(custom_class, 'eagers', {})
        page_class.css_requires = []
        page_class.js_requires = splitAndStrip(getattr(custom_class, 'js_requires', ''), ',')
        if package_js_requires:
            page_class.js_requires = uniquify(package_js_requires + page_class.js_requires)
        page_class.pageOptions = getattr(custom_class, 'pageOptions', {})
        page_class.auth_tags = getattr(custom_class, 'auth_tags', '')
        page_class.resourceDirs = self.page_class_resourceDirs(page_class, module_path, pkg=mainPkg)
        self.page_pyrequires_mixin(page_class, py_requires)
        classMixin(page_class, custom_class, only_callables=False)
        page_class.css_requires.extend([x for x in splitAndStrip(getattr(custom_class, 'css_requires', ''), ',') if x])
        if package_css_requires:
            page_class.css_requires = uniquify(page_class.css_requires+package_css_requires)
        page_class.tpldirectories = page_class.resourceDirs + [
                self.gnr_static_handler.path(page_class.gnrjsversion, 'tpl')]
        page_class._packageId = mainPkg
        self.page_class_plugin_mixin(page_class, plugin_webpage_classes)
        self.page_class_custom_mixin(page_class, relpath, pkg=mainPkg)
        self.page_factories[module_path] = page_class
        return page_class