Browse Source

Issue #70: Server now reloads configuration upon regeneration

main
Lakshmi Vyasarajan 13 years ago
parent
commit
fd9c989218
3 changed files with 20 additions and 7 deletions
  1. +3
    -1
      hyde/layouts/basic/site.yaml
  2. +15
    -6
      hyde/model.py
  3. +2
    -0
      hyde/server.py

+ 3
- 1
hyde/layouts/basic/site.yaml View File

@@ -56,4 +56,6 @@ tagger:
source: blog source: blog
target: blog/tags target: blog/tags
template: tagged_posts.j2 template: tagged_posts.j2
archive_extension: html
archive_extension: html
meta:
listable: false

+ 15
- 6
hyde/model.py View File

@@ -140,7 +140,7 @@ class Config(Expando):
""" """


def __init__(self, sitepath, config_file=None, config_dict=None): def __init__(self, sitepath, config_file=None, config_dict=None):
default_config = dict(
self.default_config = dict(
mode='production', mode='production',
content_root='content', content_root='content',
deploy_root='deploy', deploy_root='deploy',
@@ -160,11 +160,7 @@ class Config(Expando):
self.load_time = datetime.min self.load_time = datetime.min
self.config_files = [] self.config_files = []
self.sitepath = Folder(sitepath) self.sitepath = Folder(sitepath)
conf = dict(**default_config)
conf.update(self.read_config(config_file))
if config_dict:
conf.update(config_dict)
super(Config, self).__init__(conf)
super(Config, self).__init__(self.load())


@property @property
def last_modified(self): def last_modified(self):
@@ -176,6 +172,19 @@ class Config(Expando):
return any((conf.has_changed_since(self.load_time) return any((conf.has_changed_since(self.load_time)
for conf in self.config_files)) for conf in self.config_files))


def load(self):
conf = dict(**self.default_config)
conf.update(self.read_config(self.config_file))
if self.config_dict:
conf.update(self.config_dict)
return conf

def reload(self):
if not self.config_file:
return
self.update(self.load())


def read_config(self, config_file): def read_config(self, config_file):
""" """
Reads the configuration file and updates this Reads the configuration file and updates this


+ 2
- 0
hyde/server.py View File

@@ -191,6 +191,8 @@ class HydeWebServer(HTTPServer):
try: try:
logger.info('Regenerating the entire site') logger.info('Regenerating the entire site')
self.regeneration_time = datetime.now() self.regeneration_time = datetime.now()
if self.site.config.needs_refresh():
self.site.config.reload()
self.site.load() self.site.load()
self.generator.generate_all(incremental=False) self.generator.generate_all(incremental=False)
except Exception, exception: except Exception, exception:


Loading…
Cancel
Save