Browse Source

Removed regeneration on file not found. Fixed refresh param handling

main
Lakshmi Vyasarajan 13 years ago
parent
commit
5b17355142
1 changed files with 7 additions and 17 deletions
  1. +7
    -17
      hyde/server.py

+ 7
- 17
hyde/server.py View File

@@ -37,11 +37,13 @@ class HydeRequestHandler(SimpleHTTPRequestHandler):
logger.info("Processing request:[%s]" % self.path) logger.info("Processing request:[%s]" % self.path)
result = urlparse.urlparse(self.path) result = urlparse.urlparse(self.path)
query = urlparse.parse_qs(result.query) query = urlparse.parse_qs(result.query)
if 'refresh' in query:
if 'refresh' in query or result.query=='refresh':
self.server.regenerate() self.server.regenerate()
del query['refresh']
parts = tuple(result)
if 'refresh' in query:
del query['refresh']
parts = list(tuple(result))
parts[4] = urllib.urlencode(query) parts[4] = urllib.urlencode(query)
parts = tuple(parts)
new_url = urlparse.urlunparse(parts) new_url = urlparse.urlunparse(parts)
logger.info('Redirecting...[%s]' % new_url) logger.info('Redirecting...[%s]' % new_url)
self.redirect(new_url) self.redirect(new_url)
@@ -70,19 +72,7 @@ class HydeRequestHandler(SimpleHTTPRequestHandler):
res = site.content.resource_from_relative_deploy_path(path) res = site.content.resource_from_relative_deploy_path(path)


if not res: if not res:
# Check if its a new request
if self.server.request_time > self.server.regeneration_time:
# Cannot find the source file using the given path.
# Check if the target file exists in the deploy folder.

# this file is probably new or being generated by a plugin.
# lets not try too hard, just regenerate
logger.info("Attempting regeneration for:[%s]" % path)
self.server.regenerate()
res = site.content.resource_from_relative_deploy_path(path)
if not res:
# Nothing much we can do.
logger.error("Cannot load file:[%s]" % path)
logger.error("Cannot load file:[%s]" % path)


return site.config.deploy_root_path.child(path) return site.config.deploy_root_path.child(path)
else: else:
@@ -183,7 +173,7 @@ class HydeWebServer(HTTPServer):
logger.info('Regenerating the entire site') logger.info('Regenerating the entire site')
self.regeneration_time = datetime.now() self.regeneration_time = datetime.now()
self.site.load() self.site.load()
self.generator.generate_all()
self.generator.generate_all(incremental=False)
except Exception, exception: except Exception, exception:
logger.error('Error occured when regenerating the site [%s]' logger.error('Error occured when regenerating the site [%s]'
% exception.message) % exception.message)


Loading…
Cancel
Save