File: utils.py

package info (click to toggle)
django-js-reverse 0.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 240 kB
  • sloc: python: 938; makefile: 5
file content (17 lines) | stat: -rw-r--r-- 489 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# -*- coding: utf-8 -*-
try:
    from django.urls import get_script_prefix, set_script_prefix
except ImportError:
    from django.core.urlresolvers import get_script_prefix, set_script_prefix


class script_prefix(object):
    def __init__(self, newpath):
        self.newpath = newpath
        self.oldprefix = get_script_prefix()

    def __enter__(self):
        set_script_prefix(self.newpath)

    def __exit__(self, type, value, traceback):
        set_script_prefix(self.oldprefix)