Simple Class Based View Wrapper

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
"Django Extension View utilities"

class ClassView():
    """
    this acts as a 'buffer' to make class based views thread safe
    usage:
    urlpatterns = patterns('accounts',
        url(r'^new/$', ClassView(views.NewBuild), name="new"),
    )
    """

    def __init__(self, class_name):
        "store the class name in an instance variable"
        self.class_name = class_name

    def __call__(self, request, *args, **kwargs):
        """each time the class_view is invoked - for each request
        new-up a class_name and call it"""
        view = self.class_name()
        return view(request, *args, **kwargs)

More like this

  1. View and StatefulView classes by Digitalxero 4 years, 7 months ago
  2. Class based generic views that automatically check permissions by humphreymurray 2 years, 4 months ago
  3. Alternative to Class Based Views by sleepycal 8 months, 1 week ago
  4. Convenient class based views by eallik 2 years, 11 months ago
  5. Complex Form Preview by smagala 4 years, 1 month ago

Comments

(Forgotten your password?)