I'm not so sure, Tom. It took me a few minutes to deduce an answer
from the page of code you linked. And I'm extremely clever! ;)

At any rate, in the case of a middleware class consisting of just a
pass statement, at startup load_middleware will find and validate the
existence of the entry in MIDDLEWARE_CLASSES. But since the class does
not define any of the middleware methods, it will not ultimately be
registered and therefore will not consume any CPU time when handling a
request.


Hope that helps,

--Stuart

On Nov 21, 5:51 am, Tom Evans <tevans...@googlemail.com> wrote:
> On Sat, Nov 19, 2011 at 10:53 PM, Gelonida N <gelon...@gmail.com> wrote:
> > Just out of curiousity,
>
> > Let's assume I add a middleware in settings.MIDDLEWARE_CLASSES and the
> > middleware class is empty. (just a pass statement)
>
> > Will it consume any CPU time while handling a request?
>
> > To rephrase my question.
> >  Is it at startup, that Django checks which methods a middleware
> > implements . (this would be faster for most cases)
>
> > or will Django check for every request whether a midlleware has a given
> > method? (this would allow to add / remove methods in a middleware
> > dynamically)
>
> Questions like this can be quickly answered by perusing the source:
>
> https://code.djangoproject.com/browser/django/trunk/django/core/handl...
>
> Cheers
>
> Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to