[Checkins] SVN: hurry.resource/trunk/src/hurry/resource/ Make things more robust when library urls without trailing slash appear.

Martijn Faassen faassen at infrae.com
Mon Oct 6 12:14:23 EDT 2008


Log message for revision 91813:
  Make things more robust when library urls without trailing slash appear.
  

Changed:
  U   hurry.resource/trunk/src/hurry/resource/README.txt
  U   hurry.resource/trunk/src/hurry/resource/core.py

-=-
Modified: hurry.resource/trunk/src/hurry/resource/README.txt
===================================================================
--- hurry.resource/trunk/src/hurry/resource/README.txt	2008-10-06 16:11:33 UTC (rev 91812)
+++ hurry.resource/trunk/src/hurry/resource/README.txt	2008-10-06 16:14:22 UTC (rev 91813)
@@ -554,11 +554,8 @@
 resources as some static URL on localhost::
 
   >>> def get_library_url(library):
-  ...    return 'http://localhost/static/%s/' % library.name
+  ...    return 'http://localhost/static/%s' % library.name
 
-Note that the library URL should end with a ``/`` so we can add
-``inclusion.relpath`` to it.
-
 We should now register this function as a``ILibrarUrl`` adapter for
 ``Library`` so the system can find it::
 

Modified: hurry.resource/trunk/src/hurry/resource/core.py
===================================================================
--- hurry.resource/trunk/src/hurry/resource/core.py	2008-10-06 16:11:33 UTC (rev 91812)
+++ hurry.resource/trunk/src/hurry/resource/core.py	2008-10-06 16:14:22 UTC (rev 91813)
@@ -152,10 +152,14 @@
         library_urls = {}        
         for inclusion in self.inclusions(mode):
             library = inclusion.library
+            # get cached library url
             library_url = library_urls.get(library.name)
             if library_url is None:
-                library_urls[library.name] = library_url =\
-                                             interfaces.ILibraryUrl(library)
+                # if we can't find it, recalculate it
+                library_url = interfaces.ILibraryUrl(library)
+                if not library_url.endswith('/'):
+                    library_url += '/'
+                library_urls[library.name] = library_url
             result.append(render_inclusion(inclusion,
                                            library_url + inclusion.relpath))
         return '\n'.join(result)



More information about the Checkins mailing list