django-class-views-experiments /

# The aim is:
#  * get all the features here
#  * program naively
#  * and yet end up with the output:
#     Howdy; ['x']; 1
#     Howdy; ['x']; 1
#     Howdy; ['x']; 1
#     Howdy; ['x']; 1

# The naive attempt - all features, but the output is:

#   Howdy; ['x']; 1
#   Howdy; ['x', 'x']; 2
#   Howdy; ['x', 'x', 'x']; 3
#   Howdy; ['x', 'x', 'x', 'x']; 4

import threading

class View(object):

    def __call__(self, request, *args, **kwargs):
        return self.dispatch(request, *args, **kwargs)

class MyView(View):

    def __init__(self, greeting="Hello"): = [] = 0
        self.greeting = greeting

    def dispatch(self, request, *args, **kwargs): += 1'x')
        return "%s; %r; %d" % (self.greeting,,

def mydec(func):
    def _wrapper(*args, **kwargs):
        assert isinstance(args[0], HttpRequest)
        return func(*args, **kwargs)
    return _wrapper

view = mydec(MyView(greeting="Howdy"))

responses = []

class HttpRequest(object):

def runview():
    global responses
    request = HttpRequest()

# Concurrent threads:
t1 = threading.Thread(target=runview)
t2 = threading.Thread(target=runview)


# Serial threads:

for r in responses:
    print r
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.