1

This is my middleware:

class Go():
    def process_view(self, request, view_func, view_args, view_kwargs):
        aaa = "hello"
        return None

If I go into my views.py and print aaa, I get an error.

TIMEX
  • 259,804
  • 351
  • 777
  • 1,080
  • Let's just assume you're kidding about this question as written. Perhaps you could provide some real code to provide a real context for this question. – S.Lott Jan 26 '11 at 19:22
  • It's kind of important, when programming (or stitching together swathes of others' code), to be able to distinguish a local variable from other types of variable. – johnsyweb Jan 26 '11 at 21:57
  • @S.Lott: Here's the context -- http://stackoverflow.com/q/4808664/78845 – johnsyweb Jan 26 '11 at 22:26
  • 1
    @Johnsyweb: It's kind of important, when programming (or stitching together swathes of others' code), to be able to make design decisions, write code and do some debugning without posting every single step of the process as a question on Stack Overflow. – S.Lott Jan 26 '11 at 23:05
  • @S.Lott: One step at a time ;-) – johnsyweb Jan 27 '11 at 01:09
  • 1
    @Johnsyweb: One step at a time is good. Actually doing the work oneself is better. – S.Lott Jan 27 '11 at 02:49
  • @S.Lott: I couldn't agree more. – johnsyweb Jan 27 '11 at 05:09

2 Answers2

1

Try

request.aaa = "hello"

and then in your view:

print request.aaa
sunn0
  • 2,918
  • 1
  • 24
  • 25
1

If you want it available in your views, you can add anything you want to the request object as that's ultimately passed down to your views.

request.myvar = 'hello'
Yuji 'Tomita' Tomita
  • 115,817
  • 29
  • 282
  • 245