Wednesday, April 1, 2015

Re: Global access to request.user

Am 27.03.2015 um 17:16 schrieb Cal Leeming:
> Hmm this all sounds quite dirty :/
>
> However if you absolutely want to have a global object, you could try
> something like [1], although I don't recommend it at all. There are
> some situations where your modelling needs request introspection, for
> example row level auditing, but these are very specific situations and
> most of the time it's just outright abuse/bad code.

No, I don't want to use a global object. I am still searching for
a way that I like.



> If you're using template tags and performing rendering within Django,
> then you are already doing things the wrong way [2], unless your
> application has a heavy SEO requirement.

What is a better way?



> Sadly this is where the
> weaknesses of Django, and indeed many other web frameworks, start to
> appear. As such, you probably shouldn't be worrying too much about the
> "passing state around being ugly", because the code is already
> architecturally flawed and inherently ugly to start with. Also,
> abusing globals starts to get real ugly when you introduce co-routines
> and overall makes for much less readable code (imho).

Yes, I think co-routines make this worse.

Regards,
Thomas Güttler

--
--
Thomas Güttler
http://thomas-guettler.de/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/551BAE1B.2040605%40tbz-pariv.de.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment