|
|
@@ -63,8 +63,18 @@ class HydeRequestHandler(SimpleHTTPRequestHandler): |
|
|
|
path = result.path.lstrip('/') |
|
|
|
res = site.content.resource_from_relative_path(path) |
|
|
|
if not res: |
|
|
|
logger.info("Cannot load file:[%s]" % path) |
|
|
|
raise Exception("Cannot load file: [%s]" % path) |
|
|
|
# Cannot find the source file using the given path. |
|
|
|
# Check if the target file exists in the deploy folder. |
|
|
|
deployed = File(site.config.deploy_root_path.child(path)) |
|
|
|
if deployed.exists: |
|
|
|
# this file is probably being generated by a plugin. |
|
|
|
# lets not try too hard, just regenerate |
|
|
|
self.server.regenerate() |
|
|
|
return deployed.path |
|
|
|
else: |
|
|
|
logger.info("Cannot load file:[%s]" % path) |
|
|
|
raise Exception("Cannot load file: [%s]" % path) |
|
|
|
|
|
|
|
else: |
|
|
|
self.server.generate_resource(res) |
|
|
|
new_path = site.config.deploy_root_path.child( |
|
|
@@ -89,6 +99,7 @@ class HydeWebServer(HTTPServer): |
|
|
|
def __init__(self, site, address, port): |
|
|
|
self.site = site |
|
|
|
self.site.load() |
|
|
|
self.exception_count = 0 |
|
|
|
self.generator = Generator(self.site) |
|
|
|
|
|
|
|
HTTPServer.__init__(self, (address, port), |
|
|
@@ -106,9 +117,15 @@ class HydeWebServer(HTTPServer): |
|
|
|
logger.info('Regenerating the entire site') |
|
|
|
self.generator.generate_all() |
|
|
|
except Exception, exception: |
|
|
|
self.exception_count += 1 |
|
|
|
logger.error('Error occured when regenerating the site [%s]' |
|
|
|
% exception.message) |
|
|
|
self.__reinit__() |
|
|
|
if self.exception_count > 1: |
|
|
|
self.shutdown() |
|
|
|
exit() |
|
|
|
else: |
|
|
|
self.__reinit__() |
|
|
|
|
|
|
|
|
|
|
|
def generate_resource(self, resource): |
|
|
|
""" |
|
|
|