root/lib/sct/sphenecoll/sphene/community/sphpermalink.py

Revision 147:942e3ce3d7d2, 0.6 kB (checked in by Daniele Varrazzo <piro@develer.com>, 1 year ago)

Sphene package updated to r803.

Line 
1
2
3
4 # Decorator. Takes a function that returns a tuple in this format:
5 #     (viewname, viewargs, viewkwargs)
6 # Returns a function that calls urlresolvers.reverse() on that data, to return
7 # the URL for those parameters.
8 def sphpermalink(func):
9     def inner(*args, **kwargs):
10         from sphene.community.sphutils import sph_reverse
11         # Find urlconf ...
12         bits = func(*args, **kwargs)
13         viewname, args, kwargs = bits
14
15         return sph_reverse(viewname, args=args, kwargs=kwargs)
16     return inner
17
18
19 def get_urlconf():
20     from sphene.community.middleware import get_current_request
21     return getattr(get_current_request(), 'urlconf', None)
22
Note: See TracBrowser for help on using the browser.