degal/gallery.py
author Tero Marttila <terom@fixme.fi>
Wed, 01 Jul 2009 20:15:08 +0300
changeset 139 d3167c40e7b9
parent 129 a4698fa2066c
child 141 9387da0dc183
permissions -rw-r--r--
remove old scripts/cgi-bin stuff. They wouldn't work as such with the new version, and replacements can be written while referring to the history
"""
    Top-level gallery state
"""

import filesystem, folder

from utils import lazy_load

class Gallery (filesystem.Root, folder.Folder) :
    """
        A Gallery is a single place in the filesystem which acts as a Folder of Images, but had some additional stuff
    """

    def __init__ (self, path, config) :
        """
            Build a Gallery rooted at the given filesystem path, and using the given user configuration.

            XXX: replace path with config.gallery_path?
        """

        super(Gallery, self).__init__(path, config)

    @property
    def _degal_dir (self) :
        """
            The dir containing the degal configuration.
        """

        return self.subdir('.degal')

    @lazy_load
    def degal_dir (self) :
        """
            The dir containing the degal configuration.

            It will be created if it does not exist.
        """

        return self.subdir('.degal', create=True)
    
    @lazy_load
    def stylesheet (self) :
        """
            The stylesheet file.

            It will be copied from internal resources if it does not exist.
        """

        stylesheet = self.degal_dir.subfile('style.css')
        
        if not stylesheet.exists() :
            # load the resources dir
            from resources import STATIC_DIR

            # copy it from the static resource file
            stylesheet.copy_from(STATIC_DIR.subfile('style.css'))

        return stylesheet