Пример #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 = ('memphis.view:static', name, layer)

    info = config.DirectiveInfo()
    info.attach(
        config.Action(
            LayerWrapper(lambda a1,a2,a3: registry.update({a1: (a2, a3)}),
                         discriminator),
            (name, abspath, pkg),
            discriminator = discriminator))
Пример #2
0
 def layer(self, pkg, path):
     abspath, pkgname = tmpl.path(path)
     layer = self.layers.setdefault(pkg, [])
     layer.insert(0, (pkgname, abspath, path))