def main(argv=sys.argv): if len(argv) != 2: usage(argv) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) config = setup_config(settings) reg = threadlocal.get_current_registry() factory = pyramid_mako.MakoRendererFactory() name_resolver = DottedNameResolver() lookup_opts = pyramid_mako.parse_options_from_settings(settings, 'mako.', name_resolver.maybe_resolve) lookup_opts.update({ 'default_filters' : ['context[\'self\'].ddl.ddl_fmt'] }) factory.lookup = pyramid_mako.PkgResourceTemplateLookup(**lookup_opts) reg.registerUtility(factory, IRendererFactory, name='.mak') sess = DBSession() mm = ModuleManager(config) sess.execute(SetVariable('accessuid', 0)) sess.execute(SetVariable('accessgid', 0)) sess.execute(SetVariable('accesslogin', '[CREATEDB]')) mm.scan() mm.install('core', sess) for moddef in mm.modules: if moddef != 'core': mm.install(moddef, sess)
def register(): settings = config.registry.settings settings['{0}preprocessor'.format(mako_settings_prefix)] = preprocessor opts = parse_options_from_settings(settings, mako_settings_prefix, config.maybe_dotted) lookup = PkgResourceTemplateLookup(**opts) renderer_factory.lookup = lookup
def register(): registry = config.registry opts = parse_options_from_settings( registry.settings, settings_prefix, config.maybe_dotted) opts['preprocessor'] = haml.preprocessor lookup = PkgResourceTemplateLookup(**opts) renderer_factory.lookup = lookup
def setup_mako_sql(cfg): reg = threadlocal.get_current_registry() factory = pyramid_mako.MakoRendererFactory() name_resolver = DottedNameResolver() lookup_opts = pyramid_mako.parse_options_from_settings(cfg.registry.settings, 'mako.', name_resolver.maybe_resolve) lookup_opts.update({ 'default_filters' : ['context[\'self\'].ddl.ddl_fmt'] }) factory.lookup = pyramid_mako.PkgResourceTemplateLookup(**lookup_opts) reg.registerUtility(factory, IRendererFactory, name='.mak')
def mako_lookup(self): name_resolver = DottedNameResolver() lookup_opts = pyramid_mako.parse_options_from_settings( self.cfg, 'mako.', name_resolver.maybe_resolve ) lookup_opts.update({ 'output_encoding' : 'utf8', 'default_filters' : ['str'] }) return pyramid_mako.PkgResourceTemplateLookup(**lookup_opts)
def setup_mako_sql(self): if self._mako_setup: return reg = threadlocal.get_current_registry() factory = pyramid_mako.MakoRendererFactory() name_resolver = DottedNameResolver() lookup_opts = pyramid_mako.parse_options_from_settings( self.app_config.registry.settings, 'mako.', name_resolver.maybe_resolve) lookup_opts.update( {'default_filters': ['context[\'self\'].ddl.ddl_fmt']}) factory.lookup = pyramid_mako.PkgResourceTemplateLookup(**lookup_opts) reg.registerUtility(factory, IRendererFactory, name='.mak') self._mako_setup = True
def _callFUT(self, settings, settings_prefix='mako.'): from pyramid_mako import parse_options_from_settings return parse_options_from_settings(settings, settings_prefix, self.config.maybe_dotted)