-
-
Save rdm/3498932 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
import re, os, sys | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "relux.settings.local") | |
import inspect | |
from django.conf import settings | |
from django.core import urlresolvers | |
urlconf = settings.ROOT_URLCONF | |
urlresolvers.set_urlconf(urlconf) | |
resolver = urlresolvers.RegexURLResolver(r'^/', urlconf) | |
cleaner= re.compile(r'^.*django-relux') | |
while True: | |
url= sys.stdin.readline() | |
if not url: | |
exit() | |
url= url.rstrip('\r\n') | |
try: | |
callback, callback_args, callback_kwargs = resolver.resolve(url) | |
# The filename of the module that the view is defined in | |
view_filename = inspect.getsourcefile(callback) | |
view_filename= re.sub(cleaner, 'django-relux', view_filename) | |
print "%s:%s" % (view_filename, callback.__name__) | |
except: | |
print "error" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
turned it into a filter, hardcoded for relux since that was already part of the design