Ejemplo n.º 1
0
class Resource(TwistedResource):
    """
    Mamba resources base class. A web accessible resource that add common
    properties for scripts in Mamba applications
    """

    _styles_manager = appstyles.AppStyles()
    _scripts_manager = scripts.AppScripts()

    def __init__(self):
        TwistedResource.__init__(self)

        config = Application()

        # headers and render keys for root_page and index templates
        header = headers.Headers()
        self.render_keys = {
            'doctype': header.get_doctype(),
            'header': {
                'title': config.name,
                'content_type': header.content_type,
                'generator_content': header.get_generator_content(),
                'description_content': header.get_description_content(),
                'language_content': header.get_language_content(),
                'mamba_content': header.get_mamba_content(),
                'media': header.get_favicon_content('assets'),
                'styles': self._styles_manager.get_styles().values(),
                'scripts': self._scripts_manager.get_scripts().values(),
                'lessjs': Application().lessjs
            }
        }
Ejemplo n.º 2
0
    def test_shared_packages_scripts(self):

        chdir(self.currdir)
        sys.path.append('../mamba/test/dummy_app')
        config_file = tempfile.NamedTemporaryFile(delete=False)
        config_file.write(
            '{'
            '   "packages": {'
            '       "fakeshared": {"autoimport": true, "use_scripts": true}'
            '   }'
            '}')
        config_file.close()
        mgr = scripts.AppScripts(config_file_name=config_file.name)
        mgr.setup()
        self.assertEqual(len(mgr.managers), 2)
        self.assertEqual(mgr.managers[0]._scripts_store,
                         '../mamba/test/dummy_app/fakeshared/view/scripts')
        self.assertTrue('dummyshared.js' in mgr.managers[0]._scripts)
        filepath.FilePath(config_file.name).remove()
Ejemplo n.º 3
0
 def setUp(self):
     self.currdir = getcwd()
     chdir('../mamba/test/dummy_app/')
     self.mgr = scripts.AppScripts()