def includeme(config): config.include('pyramid_webassets') env = config.get_webassets_env() # Configure the static views if env.url_expire is not False: # Cache for one year (so-called "far future" Expires) config.add_static_view(env.url, env.directory, cache_max_age=31536000) else: config.add_static_view(env.url, env.directory) # Set up a predicate and subscriber to set CORS headers on asset responses config.add_subscriber_predicate('asset_request', AssetRequest) config.add_subscriber(asset_response_subscriber, pyramid.events.NewResponse, asset_request=True) loader = PythonLoader(config.registry.settings.get('h.assets', __name__)) bundles = loader.load_bundles() for bundle_name in bundles: log.info('name: ' + str(bundle_name)) config.add_webasset(bundle_name, bundles[bundle_name]) from deform.field import Field resource_registry = WebassetsResourceRegistry(config.get_webassets_env()) Field.set_default_resource_registry(resource_registry) config.registry.resources = resource_registry
def includeme(config): config.include('pyramid_webassets') env = config.get_webassets_env() # Configure the static views if env.url_expire is not False: # Cache for one year (so-called "far future" Expires) config.add_static_view(env.url, env.directory, cache_max_age=31536000) else: config.add_static_view(env.url, env.directory) # Set up a predicate and subscriber to set CORS headers on asset responses config.add_subscriber_predicate('asset_request', AssetRequest) config.add_subscriber( asset_response_subscriber, pyramid.events.NewResponse, asset_request=True ) loader = PythonLoader(config.registry.settings.get('h.assets', __name__)) bundles = loader.load_bundles() for bundle_name in bundles: log.info('name: ' + str(bundle_name)) config.add_webasset(bundle_name, bundles[bundle_name]) from deform.field import Field resource_registry = WebassetsResourceRegistry(config.get_webassets_env()) Field.set_default_resource_registry(resource_registry) config.registry.resources = resource_registry
def includeme(config): config.registry.settings.setdefault("webassets.bundles", "assets.yaml") config.include("pyramid_webassets") # Set up a predicate and subscriber to set CORS headers on asset responses config.add_subscriber_predicate("asset_request", AssetRequest) config.add_subscriber(asset_response_subscriber, pyramid.events.NewResponse, asset_request=True) resource_registry = WebassetsResourceRegistry(config.get_webassets_env()) Field.set_default_resource_registry(resource_registry) config.registry.resources = resource_registry
def includeme(config): config.registry.settings.setdefault('webassets.bundles', 'h:assets.yaml') config.include('pyramid_webassets') # Set up a predicate and subscriber to set CORS headers on asset responses config.add_subscriber_predicate('asset_request', AssetRequest) config.add_subscriber(asset_response_subscriber, pyramid.events.NewResponse, asset_request=True) resource_registry = WebassetsResourceRegistry(config.get_webassets_env()) Field.set_default_resource_registry(resource_registry) config.registry.resources = resource_registry
def includeme(config): config.include('pyramid_webassets') config.add_static_view('css', 'h:css') config.add_static_view('js', 'h:js') config.add_static_view('lib', 'h:lib') config.add_static_view('images', 'h:images') loader = PythonLoader(config.registry.settings.get('h.assets', __name__)) bundles = loader.load_bundles() for name in bundles: config.add_webasset(name, bundles[name]) from deform.field import Field resource_registry = WebassetsResourceRegistry(config.get_webassets_env()) Field.set_default_resource_registry(resource_registry) config.registry.resources = resource_registry
def includeme(config): config.include('pyramid_webassets') env = config.get_webassets_env() kw = {} if env.url_expire is not False: # Cache for one year (so-called "far future" Expires) kw['cache_max_age'] = 31536000 config.add_static_view(env.url, env.directory, **kw) loader = PythonLoader(config.registry.settings.get('h.assets', __name__)) bundles = loader.load_bundles() for name in bundles: log.info('name: ' + str(name)) config.add_webasset(name, bundles[name]) from deform.field import Field resource_registry = WebassetsResourceRegistry(config.get_webassets_env()) Field.set_default_resource_registry(resource_registry) config.registry.resources = resource_registry
def test_found_first(self): # Deform from deform.field import Field schema = DummySchema() root = self._makeOne(schema, renderer="abc") child1 = Field(schema, name="child1", parent=root) root.children = [child1] self.assertNotEqual(root.children[0].have_first_input, True) self.assertNotEqual(root.have_first_input, True) root.children[0].found_first() self.assertEqual(root.children[0].have_first_input, True) self.assertEqual(root.have_first_input, True)
def test_set_zpt_renderer(self): cls = self._getTargetClass() old = cls.default_renderer from pkg_resources import resource_filename template_dir = resource_filename('deform', 'templates/') class Field: oid = None name = None field = Field() try: cls.set_zpt_renderer(template_dir) self.assertTrue(cls.default_renderer('hidden', field=field, cstruct=None)) finally: cls.set_default_renderer(old)