| Index: sitescripts/cms/sources.py |
| =================================================================== |
| --- a/sitescripts/cms/sources.py |
| +++ b/sitescripts/cms/sources.py |
| @@ -22,16 +22,20 @@ from ConfigParser import SafeConfigParse |
| class Source: |
| def resolve_link(self, url, locale): |
| parsed = urlparse.urlparse(url) |
| page = parsed.path |
| if parsed.scheme != "" or page.startswith("/") or page.startswith("."): |
| # Not a page link |
| return None, None |
| + if parsed.path == "" and url != "": |
| + # Page-relative link |
| + return None, None |
| + |
| config = self.read_config() |
| default_locale = config.get("general", "defaultlocale") |
| default_page = config.get("general", "defaultpage") |
| checked_page = page |
| if config.has_option("locale_overrides", page): |
| checked_page = config.get("locale_overrides", page) |
| @@ -237,17 +241,21 @@ class FileSource(Source): |
| def read_file(self, filename, binary=False): |
| encoding = None if binary else "utf-8" |
| with codecs.open(self.get_path(filename), "rb", encoding=encoding) as handle: |
| return handle.read() |
| def list_files(self, subdir): |
| result = [] |
| def do_list(dir, relpath): |
| - files = os.listdir(dir) |
| + try: |
| + files = os.listdir(dir) |
| + except OSError: |
| + return |
| + |
| for filename in files: |
| path = os.path.join(dir, filename) |
| if os.path.isfile(path): |
| result.append(relpath + filename) |
| elif os.path.isdir(path): |
| do_list(path, relpath + filename + "/") |
| do_list(self.get_path(subdir), "") |
| return result |