degal/gallery.py
changeset 141 9387da0dc183
parent 129 a4698fa2066c
equal deleted inserted replaced
140:7ea9766e33ed 141:9387da0dc183
     8 
     8 
     9 class Gallery (filesystem.Root, folder.Folder) :
     9 class Gallery (filesystem.Root, folder.Folder) :
    10     """
    10     """
    11         A Gallery is a single place in the filesystem which acts as a Folder of Images, but had some additional stuff
    11         A Gallery is a single place in the filesystem which acts as a Folder of Images, but had some additional stuff
    12     """
    12     """
       
    13     
       
    14     def _init_config (self) :
       
    15         """
       
    16             Keep using our given .config
       
    17         """
       
    18 
       
    19         return self.config
    13 
    20 
    14     def __init__ (self, path, config) :
    21     def __init__ (self, path, config) :
    15         """
    22         """
    16             Build a Gallery rooted at the given filesystem path, and using the given user configuration.
    23             Build a Gallery rooted at the given filesystem path, and using the given user configuration.
    17 
    24 
    18             XXX: replace path with config.gallery_path?
    25             XXX: replace path with config.gallery_path?
    19         """
    26         """
    20 
    27 
    21         super(Gallery, self).__init__(path, config)
    28         # store config for access by Folder.__init__
       
    29         self.config = config
       
    30         
       
    31         # cooperative
       
    32         super(Gallery, self).__init__(path)
    22 
    33 
    23     @property
    34     @property
    24     def _degal_dir (self) :
    35     def _app_dir (self) :
    25         """
    36         """
    26             The dir containing the degal configuration.
    37             The dir containing our application data.
    27         """
    38         """
    28 
    39 
    29         return self.subdir('.degal')
    40         return self.subdir('.degal')
    30 
    41 
    31     @lazy_load
    42     @lazy_load
    32     def degal_dir (self) :
    43     def app_dir (self) :
    33         """
    44         """
    34             The dir containing the degal configuration.
    45             The dir containing our application data.
    35 
    46 
    36             It will be created if it does not exist.
    47             It will be created if it does not exist.
    37         """
    48         """
    38 
    49 
    39         return self.subdir('.degal', create=True)
    50         return self.subdir('.degal', create=True)
    44             The stylesheet file.
    55             The stylesheet file.
    45 
    56 
    46             It will be copied from internal resources if it does not exist.
    57             It will be copied from internal resources if it does not exist.
    47         """
    58         """
    48 
    59 
    49         stylesheet = self.degal_dir.subfile('style.css')
    60         stylesheet = self.app_dir.subfile('style.css')
    50         
    61         
    51         if not stylesheet.exists() :
    62         if not stylesheet.exists() :
    52             # load the resources dir
    63             # load the resources dir
    53             from resources import STATIC_DIR
    64             from resources import STATIC_DIR
    54 
    65 
    55             # copy it from the static resource file
    66             # copy it from the static resource file
    56             stylesheet.copy_from(STATIC_DIR.subfile('style.css'))
    67             stylesheet.copy_from(STATIC_DIR.subfile('style.css'))
       
    68         
       
    69         # elif stylesheet-is-older-than-resources-one: warn
    57 
    70 
    58         return stylesheet
    71         return stylesheet
    59 
    72