#8182 closed (fixed)
infinite loop iterating over context_processors.PermWrapper
Reported by: | Uz | Owned by: | |
---|---|---|---|
Component: | contrib.auth | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The template code below will cause an infinite memory-eating loop if context_processors.auth is enabled. My main issue with that is that it was incredibly hard to debug for me, when I passed my own 'perms' queryset to a template. So here's a (temporary) patch, to make it at least immediately fail.
{% for perm in perms %} {% endfor %}
Attachments (2)
Change History (8)
by , 16 years ago
Attachment: | permwrapper.patch.bz2 added |
---|
comment:1 by , 16 years ago
comment:2 by , 16 years ago
possible alternative?
def __iter__(self): for p in self.user.get_all_permissions(): yield p
by , 16 years ago
Attachment: | 8182_with_docs.diff added |
---|
comment:3 by , 16 years ago
Added improved patch, which makes use of cgrady's idea.
The use of self.user.get_all_permissions() raised another problem -- this method doesn't exist for AnonymousUser. So I added the missing methods from User to the AnonymousUser class, providing adequate return values or raising NotImplementedError.
Updated docs for AnonymousUser as well.
comment:4 by , 16 years ago
Has patch: | set |
---|
comment:5 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
permwrapper.patch only adds this to the PermWrapper class: