Mercurial > p > roundup > code
comparison roundup/admin.py @ 3894:44f2158fe76e
Marek Kubica's patch to find templates installed by easy_install
Adds one more place to look for templates. We already look in several
places, trying to find them. This adds one more. When you install via
easy_install the hierarchy ends up looking like:
/usr/lib/python2.5/site-packages/roundup-1.3.3-py2.5.egg/roundup/admin.py
/usr/lib/python2.5/site-packages/roundup-1.3.3-py2.5.egg/share/roundup/templates/*
| author | Justus Pendleton <jpend@users.sourceforge.net> |
|---|---|
| date | Tue, 11 Sep 2007 04:12:17 +0000 |
| parents | f7766d5ba962 |
| children | d02aad94af5a |
comparison
equal
deleted
inserted
replaced
| 3893:1bf9a4b4de33 | 3894:44f2158fe76e |
|---|---|
| 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 18 # | 18 # |
| 19 # $Id: admin.py,v 1.107 2007-09-07 20:18:15 jpend Exp $ | 19 # $Id: admin.py,v 1.108 2007-09-11 04:12:17 jpend Exp $ |
| 20 | 20 |
| 21 '''Administration commands for maintaining Roundup trackers. | 21 '''Administration commands for maintaining Roundup trackers. |
| 22 ''' | 22 ''' |
| 23 __docformat__ = 'restructuredtext' | 23 __docformat__ = 'restructuredtext' |
| 24 | 24 |
| 285 def listTemplates(self): | 285 def listTemplates(self): |
| 286 ''' List all the available templates. | 286 ''' List all the available templates. |
| 287 | 287 |
| 288 Look in the following places, where the later rules take precedence: | 288 Look in the following places, where the later rules take precedence: |
| 289 | 289 |
| 290 1. <prefix>/share/roundup/templates/* | 290 1. <roundup.admin.__file__>/../../share/roundup/templates/* |
| 291 this is where they will be if we installed an egg via easy_install | |
| 292 2. <prefix>/share/roundup/templates/* | |
| 291 this should be the standard place to find them when Roundup is | 293 this should be the standard place to find them when Roundup is |
| 292 installed | 294 installed |
| 293 2. <roundup.admin.__file__>/../templates/* | 295 3. <roundup.admin.__file__>/../templates/* |
| 294 this will be used if Roundup's run in the distro (aka. source) | 296 this will be used if Roundup's run in the distro (aka. source) |
| 295 directory | 297 directory |
| 296 3. <current working dir>/* | 298 4. <current working dir>/* |
| 297 this is for when someone unpacks a 3rd-party template | 299 this is for when someone unpacks a 3rd-party template |
| 298 4. <current working dir> | 300 5. <current working dir> |
| 299 this is for someone who "cd"s to the 3rd-party template dir | 301 this is for someone who "cd"s to the 3rd-party template dir |
| 300 ''' | 302 ''' |
| 301 # OK, try <prefix>/share/roundup/templates | 303 # OK, try <prefix>/share/roundup/templates |
| 304 # and <egg-directory>/share/roundup/templates | |
| 302 # -- this module (roundup.admin) will be installed in something | 305 # -- this module (roundup.admin) will be installed in something |
| 303 # like: | 306 # like: |
| 304 # /usr/lib/python2.2/site-packages/roundup/admin.py (5 dirs up) | 307 # /usr/lib/python2.5/site-packages/roundup/admin.py (5 dirs up) |
| 305 # c:\python22\lib\site-packages\roundup\admin.py (4 dirs up) | 308 # c:\python25\lib\site-packages\roundup\admin.py (4 dirs up) |
| 306 # we're interested in where the "lib" directory is - ie. the /usr/ | 309 # /usr/lib/python2.5/site-packages/roundup-1.3.3-py2.5-egg/roundup/admin.py |
| 307 # part | 310 # (2 dirs up) |
| 311 # | |
| 312 # we're interested in where the directory containing "share" is | |
| 308 templates = {} | 313 templates = {} |
| 309 for N in 4, 5: | 314 for N in 2, 4, 5: |
| 310 path = __file__ | 315 path = __file__ |
| 311 # move up N elements in the path | 316 # move up N elements in the path |
| 312 for i in range(N): | 317 for i in range(N): |
| 313 path = os.path.dirname(path) | 318 path = os.path.dirname(path) |
| 314 tdir = os.path.join(path, 'share', 'roundup', 'templates') | 319 tdir = os.path.join(path, 'share', 'roundup', 'templates') |
