| 228 | tag_dirs = () |
| 229 | try: |
| 230 | from django.conf.settings import TEMPLATETAG_DIRS |
| 231 | tag_dirs = TEMPLATETAG_DIRS |
| 232 | except ImportError: |
| 233 | pass |
| 234 | |
| 235 | # save sys.path for later restoration |
| 236 | import sys |
| 237 | syspath = sys.path[:] |
| 238 | |
| 239 | # set the first element of sys.path to each entry of |
| 240 | # TEMPLATETAG_DIRS, then try the import. |
| 241 | sys.path.insert(0, '') |
| 242 | for tag_dir in tag_dirs: |
| 243 | sys.path[0] = tag_dir |
| 244 | try: |
| 245 | mod = __import__("%s" % taglib.split('.')[-1], '', '', ['']) |
| 246 | except ImportError: |
| 247 | continue |
| 248 | # restore sys.path |
| 249 | reload(mod) |
| 250 | sys.path = syspath[:] |
| 251 | return mod |
| 252 | # restore sys.path |
| 253 | sys.path = syspath[:] |
| 254 | |
| 255 | # one more try without path manipulation |