[Checkins] SVN: zc.resourcelibrary/trunk/src/zc/resourcelibrary/
included urls are now absolute, this needed for e.g ++skin++ urls
Bernd Dorn
bernd.dorn at fhv.at
Wed Aug 16 11:00:53 EDT 2006
Log message for revision 69563:
included urls are now absolute, this needed for e.g ++skin++ urls
Changed:
U zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt
U zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py
-=-
Modified: zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt 2006-08-16 13:16:16 UTC (rev 69562)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt 2006-08-16 15:00:53 UTC (rev 69563)
@@ -112,6 +112,14 @@
alert('Hi there!');
}
+For inclusion of resources the full base url with namespaces is used.
+
+ >>> browser.open('http://localhost/++skin++Basic/zc.resourcelibrary.test_template_2')
+ >>> print browser.contents
+ <html...
+ src="http://localhost/++skin++Basic/@@/my-lib/included.js"...
+ </html>
+
A reference to the CSS is also inserted into the HTML.
>>> browser.open('http://localhost/zc.resourcelibrary.test_template_2')
Modified: zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py 2006-08-16 13:16:16 UTC (rev 69562)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py 2006-08-16 15:00:53 UTC (rev 69563)
@@ -19,6 +19,9 @@
from zope.publisher.browser import BrowserRequest, BrowserResponse
from zope.publisher.browser import isHTML
import zc.resourcelibrary.zcml
+from zope.app.component.hooks import getSite
+from zope.component import getMultiAdapter
+from zope.traversing.browser.interfaces import IAbsoluteURL
class Request(BrowserRequest):
interface.classProvides(IBrowserRequestFactory)
@@ -33,7 +36,6 @@
class Response(BrowserResponse):
def _implicitResult(self, body):
-
#figure out the content type
content_type = self.getHeader('content-type')
if content_type is None:
@@ -64,19 +66,23 @@
# generate the HTML that will be included in the response
html = []
+ site = getSite()
+ baseURL = str(getMultiAdapter((site, self._request),
+ IAbsoluteURL))
for lib in self.resource_libraries:
included = zc.resourcelibrary.getIncluded(lib)
for file_name in included:
if file_name.endswith('.js'):
- html.append('<script src="/@@/%s/%s" '
- 'language="Javascript1.1"' % (lib, file_name))
+ html.append('<script src="%s/@@/%s/%s" '
+ 'language="Javascript1.1"'
+ % (baseURL, lib, file_name))
html.append(' type="text/javascript">')
html.append('</script>')
elif file_name.endswith('.css'):
html.append('<style type="text/css" media="all">')
html.append(' <!--')
- html.append(' @import url("/@@/%s/%s");'
- % (lib, file_name))
+ html.append(' @import url("%s/@@/%s/%s");'
+ % (baseURL, lib, file_name))
html.append(' -->')
html.append('</style>')
else:
More information about the Checkins
mailing list