1 class SsifyError(BaseException):
5 class SsifyWarning(Warning):
9 class UndeclaredSsiVarsError(SsifyError):
10 def __init__(self, request, ssi_vars):
11 super(UndeclaredSsiVarsError, self).__init__(request, ssi_vars)
14 request = self.args[0]
15 view = request.resolver_match.func
16 return "The view '%s.%s' at '%s' is marked as `ssi_included`, "\
17 "but it uses ssi variables not declared in `get_ssi_vars` "\
19 view.__module__, view.__name__, request.path,
23 class UnusedSsiVarsWarning(SsifyWarning):
24 def __init__(self, request, ssi_vars):
25 super(UnusedSsiVarsWarning, self).__init__(request, ssi_vars)
28 request = self.args[0]
29 view = request.resolver_match.func
30 return "The `ssi_included` view '%s.%s' at '%s' declares "\
31 "using SSI variables %s but it looks like they're not "\
33 view.__module__, view.__name__, request.path, self.args[1])
36 class UndeclaredSsiRefError(SsifyError):
37 def __init__(self, request, var, ref_name):
38 super(UndeclaredSsiRefError, self).__init__(request, var, ref_name)
41 request = self.args[0]
42 view = request.resolver_match.func
43 return "Error while rendering ssi_included view '%s.%s' at '%s': "\
44 "SSI variable %s references variable %s, which doesn't match "\
45 "any variable declared in `get_ssi_vars`. " % (
46 view.__module__, view.__name__, request.path,
47 repr(self.args[1]), self.args[2])
50 class NoLangFieldError(SsifyError):
51 def __init__(self, request):
52 super(NoLangFieldError, self).__init__(request)
55 request = self.args[0]
56 view = request.resolver_match.func
57 return "The view '%s.%s' at '%s' is marked as `ssi_included` "\
58 "with use_lang=True, but its URL match doesn't provide "\
59 "a 'lang' keyword argument for language. " % (
60 view.__module__, view.__name__, request.path)
63 class SsiVarsDependencyCycleError(SsifyError):
64 def __init__(self, ssi_vars):
65 super(SsiVarsDependencyCycleError, self).__init__(ssi_vars)
68 return "Dependency cycle in SSI variables: %s." % self.args[0]