|
[Webware-discuss] recipe.webkit.Importing servlets from your
parent directory, Part 2
From: Chuck Esterbrook <echuck@mi...> - 2001-03-25 23:51
|
Part 2:
Since my site also has top level directories such as Graphics/ JavaScript/
etc. as well as a StyleSheet.css in the main directory, I need a convenient
way to refer to these from subdirectories.
I do this by prepending a string I call the "root dir" to my relative links:
def rootDir(self):
'''
Returns the root directory of the site appropriate for prepending to
relative paths, such as Graphics/foo.gif. Will return '', '../', '../../', etc.
'''
parts = self.request().urlPath().split('/')
numExtraParts = len(parts) - parts.index('MyContext') - 2
return '../' * numExtraParts
So I might have a link that looks like this:
'%sStyleSheet.css' % self.rootDir()
My host name, WebKit adapter name and context name can change at any time
and the existing code will work fine since I use ../
Upon deployment to the production environment, I could leave this as is, or
change rootDir() to return 'http://www.host.com/'.
-Chuck
|
| Thread | Author | Date |
|---|---|---|
| [Webware-discuss] recipe.webkit.Importing servlets from your parent directory, Part 2 | Chuck Esterbrook <echuck@mi...> |