Exemple #1
0
def static(name, path, layer=''):
    """ Register new static assets directory

    :param name: Resource name
    :param path: Filesystem path
    """
    abspath, pkg = tmpl.path(path)
    data = registry[name] = [abspath, pkg]

    if not abspath:
        raise ValueError("Can't find path to static resource")

    if not os.path.isdir(abspath):
        raise ValueError("path is not directory")

    discriminator = ('ptah.view:static', name, layer)

    info = config.DirectiveInfo()
    info.attach(
        config.Action(
            LayerWrapper(lambda config, a1,a2,a3: \
                         registry.update({a1: (a2, a3)}), discriminator),
            (name, abspath, pkg),
            discriminator = discriminator))
Exemple #2
0
def static(name, path, layer=''):
    """ Register new static assets directory

    :param name: Resource name
    :param path: Filesystem path
    """
    abspath, pkg = tmpl.path(path)

    if not abspath:
        raise ValueError("Can't find path to static resource")

    if not os.path.isdir(abspath):
        raise ValueError("path is not directory")

    discriminator = (STATIC_ID, name, layer)

    info = config.DirectiveInfo()
    info.attach(
        config.Action(
            LayerWrapper(lambda cfg, a1,a2,a3: \
                         cfg.get_cfg_storage(STATIC_ID)\
                             .update({a1: (a2, a3)}), discriminator),
            (name, abspath, pkg),
            discriminator = discriminator))
Exemple #3
0
 def layer(self, pkg, path):
     abspath, pkgname = tmpl.path(path)
     layer = self.layers.setdefault(pkg, [])
     layer.insert(0, (pkgname, abspath, path))
Exemple #4
0
 def test_tmpl_relative(self):
     path, pkg = tapi.path('templates/msg-error.pt')
     self.assertEqual(path, None)
     self.assertEqual(pkg, 'ptah.view.tests')