# HG changeset patch # User Tero Marttila # Date 1246043353 -10800 # Node ID 6534c77de93fa3064a04810b85c11d4d307a1796 # Parent ea05fe81ff67dad8a29f2eb1503c0b800d584a6a urlencode native filesystem node paths for template's http URLs diff -r ea05fe81ff67 -r 6534c77de93f degal/config.py --- a/degal/config.py Wed Jun 17 18:11:38 2009 +0300 +++ b/degal/config.py Fri Jun 26 22:09:13 2009 +0300 @@ -99,6 +99,7 @@ def debug (self) : self.log_level = logging.DEBUG # number of threads to use for concurrency + # use some heuristic? thread_count = 2 # the name of this folder, only applies on one level diff -r ea05fe81ff67 -r 6534c77de93f degal/templates.py --- a/degal/templates.py Wed Jun 17 18:11:38 2009 +0300 +++ b/degal/templates.py Fri Jun 26 22:09:13 2009 +0300 @@ -5,14 +5,26 @@ import html, version from html import tags +import urllib + +def quote_path (path) : + """ + Return an unicode-safe string with the escaped contents of the given str-able object, suitable for use + in HTTP URLs. + + This should provide correct behaviour for use with filesystem Nodes. + + XXX: even this could be abstracted to some kind of "URL" thing + """ + + return urllib.quote(str(path)) + def link_from (source, target) : """ - Returns a partial a tag linking from the given page to the given page - - XXX: URLEncode unicode -> str! + Returns a partial a tag linking from the given source page to the target page, escaping binary paths. """ - return tags.a(href=source.path_to(target)) + return tags.a(href=quote_path(source.path_to(target))) def image_link (from_page, image, target) : """ @@ -20,7 +32,7 @@ """ return link_from(from_page, target)( - tags.img(src=image.path_from(from_page)) + tags.img(src=quote_path(image.path_from(from_page))) ) def image_page (image) :